Diff
1diff --git a/ui/common/utils.go b/ui/common/utils.go
2index 97d498cb63ca1b77e7565d60dd870b4aff9d7575..6ed9b714d445bc602bc6ab004bb15172e4555f78 100644
3--- a/ui/common/utils.go
4+++ b/ui/common/utils.go
5@@ -16,8 +16,8 @@ func TruncateString(s string, max int) string {
6 return truncate.StringWithTail(s, uint(max), "…")
7 }
8
9-// CloneCmd returns the URL of the repository.
10-func CloneCmd(publicURL, name string) string {
11+// RepoURL returns the URL of the repository.
12+func RepoURL(publicURL, name string) string {
13 name = utils.SanitizeRepo(name) + ".git"
14 url, err := url.Parse(publicURL)
15 if err == nil {
16@@ -25,12 +25,17 @@ func CloneCmd(publicURL, name string) string {
17 case "ssh":
18 port := url.Port()
19 if port == "" || port == "22" {
20- return fmt.Sprintf("git clone git@%s:%s", url.Hostname(), name)
21+ return fmt.Sprintf("git@%s:%s", url.Hostname(), name)
22 } else {
23- return fmt.Sprintf("git clone ssh://%s:%s/%s", url.Hostname(), url.Port(), name)
24+ return fmt.Sprintf("ssh://%s:%s/%s", url.Hostname(), url.Port(), name)
25 }
26 }
27 }
28
29- return fmt.Sprintf("git clone %s/%s", publicURL, name)
30+ return fmt.Sprintf("%s/%s", publicURL, name)
31+}
32+
33+// CloneCmd returns the URL of the repository.
34+func CloneCmd(publicURL, name string) string {
35+ return fmt.Sprintf("git clone %s", RepoURL(publicURL, name))
36 }
37diff --git a/ui/pages/repo/empty.go b/ui/pages/repo/empty.go
38index 1e62e8f869988c8f2c525b03b2d67e24a384c42f..fe3921d9c66fe1d6619a412a33558b418fa41694 100644
39--- a/ui/pages/repo/empty.go
40+++ b/ui/pages/repo/empty.go
41@@ -36,5 +36,5 @@ git push -u origin main
42 git remote add origin %[1]s
43 git push -u origin main
44 `+"```"+`
45-`, common.CloneCmd(cfg.SSH.PublicURL, repo))
46+`, common.RepoURL(cfg.SSH.PublicURL, repo))
47 }