fix(repo): stop advertising HTTP clone URLs when DISABLE_HTTP_GIT is set (#38378)

Fixes #38339

---------

Signed-off-by: TowyTowy <towy@airreps.link>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
TowyTowy
2026-07-17 05:17:28 +00:00
committed by GitHub
co-authored by wxiaoguang
parent bca44bd736
commit 8a3daef525
12 changed files with 115 additions and 115 deletions
+10 -3
View File
@@ -647,6 +647,10 @@ func (repo *Repository) DescriptionHTML(ctx context.Context) template.HTML {
// CloneLink represents different types of clone URLs of repository.
type CloneLink struct {
IsWikiRepo bool
SupportSSH bool
SupportHTTPS bool
SSH string
HTTPS string
Tea string
@@ -698,9 +702,12 @@ func ComposeTeaCloneCommand(ctx context.Context, owner, repo string) string {
func (repo *Repository) cloneLink(ctx context.Context, doer *user_model.User, repoPathName string) *CloneLink {
return &CloneLink{
SSH: ComposeSSHCloneURL(doer, repo.OwnerName, repoPathName),
HTTPS: ComposeHTTPSCloneURL(ctx, repo.OwnerName, repoPathName),
Tea: ComposeTeaCloneCommand(ctx, repo.OwnerName, repoPathName),
IsWikiRepo: strings.HasSuffix(repoPathName, ".wiki"),
SupportHTTPS: !setting.Repository.DisableHTTPGit,
SupportSSH: !setting.SSH.Disabled && (doer != nil || setting.SSH.ExposeAnonymous),
SSH: ComposeSSHCloneURL(doer, repo.OwnerName, repoPathName),
HTTPS: ComposeHTTPSCloneURL(ctx, repo.OwnerName, repoPathName),
Tea: ComposeTeaCloneCommand(ctx, repo.OwnerName, repoPathName),
}
}