From 7b749047cbd7fb06d02dba4777f5d3d12c022e25 Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Wed, 21 Sep 2022 10:57:42 +0800 Subject: [PATCH 1/3] fix clone vsc --- templates/repo/home.tmpl | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/templates/repo/home.tmpl b/templates/repo/home.tmpl index 2f9b1f25b734e..18c02aa9ecac5 100644 --- a/templates/repo/home.tmpl +++ b/templates/repo/home.tmpl @@ -116,19 +116,19 @@ {{if eq $n 0}}
- {{template "repo/clone_buttons" .}} - {{template "repo/clone_script" .}} - + {{template "repo/clone_buttons" .}} + + {{template "repo/clone_script" .}}{{/* the script will update `.js-clone-url` and related elements */}}
{{end}} {{if and (ne $n 0) (not .IsViewFile) (not .IsBlame) }} From 7348679a48c363c5ec4a599986d3319191b84481 Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Thu, 22 Sep 2022 09:13:13 +0800 Subject: [PATCH 2/3] fix template bug --- templates/repo/clone_script.tmpl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/templates/repo/clone_script.tmpl b/templates/repo/clone_script.tmpl index 5c9a545caddf9..029a59662dd7e 100644 --- a/templates/repo/clone_script.tmpl +++ b/templates/repo/clone_script.tmpl @@ -21,8 +21,9 @@ for (const el of document.getElementsByClassName('js-clone-url')) { el[el.nodeName === 'INPUT' ? 'value' : 'textContent'] = link; } + const sep = '//'; // Golang's template has a bug with string interpolation containing slashes, the double slash will be treated as a comment there for (const el of document.getElementsByClassName('js-clone-url-vsc')) { - el['href'] = `vscode://vscode.git/clone?url=${encodeURIComponent(link)}`; + el.href = `vscode:${sep}vscode.git/clone?url=${encodeURIComponent(link)}`; } })(); From f8b2bc1ae452a0fffa4d5be624e8aa4d1c3f4c5d Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Thu, 22 Sep 2022 09:21:37 +0800 Subject: [PATCH 3/3] add more comments --- templates/repo/clone_script.tmpl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/templates/repo/clone_script.tmpl b/templates/repo/clone_script.tmpl index 029a59662dd7e..97fd61d83dbcd 100644 --- a/templates/repo/clone_script.tmpl +++ b/templates/repo/clone_script.tmpl @@ -1,3 +1,6 @@ +{{/*Golang's template has a bug with string interpolation containing slashes, +the double slash will be treated as a comment there. +But there are also JS lint rules for template that require to use string interpolation in 1.17*/}}