From 144c929c152986d9e9f49233ed9b01087c275e7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miika=20Pet=C3=A4j=C3=A4niemi?= Date: Tue, 27 Mar 2018 17:19:11 +0300 Subject: [PATCH] use ssh domain for go-import meta tag if http git is disabled --- pkg/context/context.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pkg/context/context.go b/pkg/context/context.go index ed97395bf..ae3e39429 100644 --- a/pkg/context/context.go +++ b/pkg/context/context.go @@ -243,6 +243,16 @@ func Contexter() macaron.Handler { branchName = repo.DefaultBranch } + cloneLink := models.ComposeHTTPSCloneURL(ownerName, repoName) + + if setting.Repository.DisableHTTPGit { + if setting.SSH.Port != 22 { + cloneLink = fmt.Sprintf("ssh://%s@%s:%d/%s/%s.git", setting.RunUser, setting.SSH.Domain, setting.SSH.Port, ownerName, repoName) + } else { + cloneLink = fmt.Sprintf("%s@%s:%s/%s.git", setting.RunUser, setting.SSH.Domain, ownerName, repoName) + } + } + prefix := setting.AppURL + path.Join(ownerName, repoName, "src", branchName) c.PlainText(http.StatusOK, []byte(com.Expand(`