0
0
mirror of https://github.com/go-gitea/gitea.git synced 2026-04-04 10:05:18 +02:00

add group id segment to repository's Link method

This commit is contained in:
☙◦ The Tablet ❀ GamerGirlandCo ◦❧ 2025-08-17 22:05:22 -04:00
parent e2c6623244
commit ae8a64cd74
No known key found for this signature in database
GPG Key ID: 924A5F6AF051E87C

View File

@ -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.