From be5411d6b576a3dd281e3e0ab016c02edfad77bb Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Fri, 23 Sep 2022 12:10:26 +0800 Subject: [PATCH] Make Clone in VSCode link get updated correctly (#21225) (#21226) Backport #21225, fix for #21128 (also in 1.17.3), close #21224 The indent was incorrect before, so this PR did some formatting work. Bypass Golang's template bug for JS string interpolation. And since there are JS lint rules for templates, so the string interpolation is also a must. --- templates/repo/clone_script.tmpl | 6 +++++- templates/repo/home.tmpl | 26 +++++++++++++------------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/templates/repo/clone_script.tmpl b/templates/repo/clone_script.tmpl index 5c9a545caddf..97fd61d83dbc 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*/}} diff --git a/templates/repo/home.tmpl b/templates/repo/home.tmpl index 2f9b1f25b734..18c02aa9ecac 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) }}