From ae8a64cd74274333336fb76c1a32c12c6f0d83fe 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 7a7edb29fb..84a4a5a2ed 100644 --- a/models/repo/repo.go +++ b/models/repo/repo.go @@ -607,7 +607,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 @@ -675,7 +675,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 } @@ -709,7 +709,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) @@ -718,9 +718,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.