fix(ui): empty repo clone command

Ayman Bagabas created

Change summary

ui/common/utils.go     | 15 ++++++++++-----
ui/pages/repo/empty.go |  2 +-
2 files changed, 11 insertions(+), 6 deletions(-)

Detailed changes

ui/common/utils.go 🔗

@@ -16,8 +16,8 @@ func TruncateString(s string, max int) string {
 	return truncate.StringWithTail(s, uint(max), "…")
 }
 
-// CloneCmd returns the URL of the repository.
-func CloneCmd(publicURL, name string) string {
+// RepoURL returns the URL of the repository.
+func RepoURL(publicURL, name string) string {
 	name = utils.SanitizeRepo(name) + ".git"
 	url, err := url.Parse(publicURL)
 	if err == nil {
@@ -25,12 +25,17 @@ func CloneCmd(publicURL, name string) string {
 		case "ssh":
 			port := url.Port()
 			if port == "" || port == "22" {
-				return fmt.Sprintf("git clone git@%s:%s", url.Hostname(), name)
+				return fmt.Sprintf("git@%s:%s", url.Hostname(), name)
 			} else {
-				return fmt.Sprintf("git clone ssh://%s:%s/%s", url.Hostname(), url.Port(), name)
+				return fmt.Sprintf("ssh://%s:%s/%s", url.Hostname(), url.Port(), name)
 			}
 		}
 	}
 
-	return fmt.Sprintf("git clone %s/%s", publicURL, name)
+	return fmt.Sprintf("%s/%s", publicURL, name)
+}
+
+// CloneCmd returns the URL of the repository.
+func CloneCmd(publicURL, name string) string {
+	return fmt.Sprintf("git clone %s", RepoURL(publicURL, name))
 }

ui/pages/repo/empty.go 🔗

@@ -36,5 +36,5 @@ git push -u origin main
 git remote add origin %[1]s
 git push -u origin main
 `+"```"+`
-`, common.CloneCmd(cfg.SSH.PublicURL, repo))
+`, common.RepoURL(cfg.SSH.PublicURL, repo))
 }