From cd40705a89b7ae658788fe35726984098c8b472d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=98=99=E2=97=A6=20The=20Tablet=20=E2=9D=80=20GamerGirla?= =?UTF-8?q?ndCo=20=E2=97=A6=E2=9D=A7?= Date: Sun, 17 Aug 2025 22:05:22 -0400 Subject: [PATCH] add group id segment to repository's `Link` method --- models/repo/repo.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/models/repo/repo.go b/models/repo/repo.go index c1cc129f49..80fc35a5af 100644 --- a/models/repo/repo.go +++ b/models/repo/repo.go @@ -608,7 +608,7 @@ func (repo *Repository) RepoPath() string { // Link returns the repository relative url func (repo *Repository) Link() string { - return setting.AppSubURL + "/" + url.PathEscape(repo.OwnerName) + "/" + url.PathEscape(repo.Name) + return setting.AppSubURL + "/" + url.PathEscape(repo.OwnerName) + "/" + groupSegmentWithTrailingSlash(repo.GroupID) + url.PathEscape(repo.Name) } // ComposeCompareURL returns the repository comparison URL @@ -676,7 +676,7 @@ type CloneLink struct { func getGroupSegment(gid int64) string { var groupSegment string if gid > 0 { - groupSegment = fmt.Sprintf("%d", gid) + groupSegment = fmt.Sprintf("group/%d", gid) } return groupSegment } @@ -710,7 +710,7 @@ func ComposeSSHCloneURL(doer *user_model.User, ownerName, repoName string, group // non-standard port, it must use full URI if setting.SSH.Port != 22 { sshHost := net.JoinHostPort(sshDomain, strconv.Itoa(setting.SSH.Port)) - return fmt.Sprintf("ssh://%s@%s/%s%s/%s.git", sshUser, sshHost, url.PathEscape(ownerName), groupSegmentWithTrailingSlash(groupID), url.PathEscape(repoName)) + return fmt.Sprintf("ssh://%s@%s/%s/%s%s.git", sshUser, sshHost, url.PathEscape(ownerName), groupSegmentWithTrailingSlash(groupID), url.PathEscape(repoName)) } // for standard port, it can use a shorter URI (without the port) @@ -719,9 +719,9 @@ func ComposeSSHCloneURL(doer *user_model.User, ownerName, repoName string, group sshHost = "[" + sshHost + "]" // for IPv6 address, wrap it with brackets } if setting.Repository.UseCompatSSHURI { - return fmt.Sprintf("ssh://%s@%s/%s/%s.git", sshUser, sshHost, url.PathEscape(ownerName), url.PathEscape(repoName)) + return fmt.Sprintf("ssh://%s@%s/%s/%s%s.git", sshUser, sshHost, url.PathEscape(ownerName), groupSegmentWithTrailingSlash(groupID), url.PathEscape(repoName)) } - return fmt.Sprintf("%s@%s:%s/%s.git", sshUser, sshHost, url.PathEscape(ownerName), url.PathEscape(repoName)) + return fmt.Sprintf("%s@%s:%s/%s%s.git", sshUser, sshHost, url.PathEscape(ownerName), groupSegmentWithTrailingSlash(groupID), url.PathEscape(repoName)) } // ComposeTeaCloneCommand returns Tea CLI clone command based on the given owner and repository name.