Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the vscode clone link respect transport protocol #20557

Merged
merged 14 commits into from
Sep 9, 2022
8 changes: 7 additions & 1 deletion templates/repo/clone_script.tmpl
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<script>
// synchronously set clone button states and urls here to avoid flickering
// on page load. initRepoCloneLink calls this when proto changes.
// this applies the protocol-dependant clone url to all elements with the
// `js-clone-url` and `js-clone-url-vs` classes.
wxiaoguang marked this conversation as resolved.
Show resolved Hide resolved
// TODO: This localStorage setting should be moved to backend user config
// so it's available during rendering, then this inline script can be removed.
(window.updateCloneStates = function() {
Expand All @@ -17,7 +19,11 @@

const link = btn.getAttribute('data-link');
for (const el of document.getElementsByClassName('js-clone-url')) {
el[el.nodeName === 'INPUT' ? 'value' : 'textContent'] = link;
const attr = (el.nodeName === 'INPUT') ? 'value' : 'textContent';
el[attr] = link;
wxiaoguang marked this conversation as resolved.
Show resolved Hide resolved
}
for (const el of document.getElementsByClassName('js-clone-url-vs')) {
wxiaoguang marked this conversation as resolved.
Show resolved Hide resolved
el['href'] = 'vscode://vscode.git/clone?url=' + encodeURIComponent(link);
}
})();
</script>
2 changes: 1 addition & 1 deletion templates/repo/home.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
<a class="item archive-link" href="{{$.RepoLink}}/archive/{{PathEscapeSegments $.BranchName}}.tar.gz" rel="nofollow">{{svg "octicon-file-zip" 16 "mr-3"}}{{.locale.Tr "repo.download_tar"}}</a>
<a class="item archive-link" href="{{$.RepoLink}}/archive/{{PathEscapeSegments $.BranchName}}.bundle" rel="nofollow">{{svg "octicon-package" 16 "mr-3"}}{{.locale.Tr "repo.download_bundle"}}</a>
{{end}}
<a class="item" href="vscode://vscode.git/clone?url={{$.RepoCloneLink.HTTPS}}">{{svg "gitea-vscode" 16 "mr-3"}}{{.locale.Tr "repo.clone_in_vsc"}}</a>
<a class="item js-clone-url-vs" href="vscode://vscode.git/clone?url={{.CloneButtonOriginLink.HTTPS}}">{{svg "gitea-vscode" 16 "mr-3"}}{{.locale.Tr "repo.clone_in_vsc"}}</a>
wxiaoguang marked this conversation as resolved.
Show resolved Hide resolved
</div>
</button>
</div>
Expand Down