0
0
mirror of https://github.com/go-gitea/gitea.git synced 2026-05-13 02:25:40 +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 88c0bf4530
commit cd40705a89
No known key found for this signature in database
GPG Key ID: 924A5F6AF051E87C

View File

@ -608,7 +608,7 @@ func (repo *Repository) RepoPath() string {
// Link returns the repository relative url // Link returns the repository relative url
func (repo *Repository) Link() string { 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 // ComposeCompareURL returns the repository comparison URL
@ -676,7 +676,7 @@ type CloneLink struct {
func getGroupSegment(gid int64) string { func getGroupSegment(gid int64) string {
var groupSegment string var groupSegment string
if gid > 0 { if gid > 0 {
groupSegment = fmt.Sprintf("%d", gid) groupSegment = fmt.Sprintf("group/%d", gid)
} }
return groupSegment return groupSegment
} }
@ -710,7 +710,7 @@ func ComposeSSHCloneURL(doer *user_model.User, ownerName, repoName string, group
// non-standard port, it must use full URI // non-standard port, it must use full URI
if setting.SSH.Port != 22 { if setting.SSH.Port != 22 {
sshHost := net.JoinHostPort(sshDomain, strconv.Itoa(setting.SSH.Port)) 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) // 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 sshHost = "[" + sshHost + "]" // for IPv6 address, wrap it with brackets
} }
if setting.Repository.UseCompatSSHURI { 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. // ComposeTeaCloneCommand returns Tea CLI clone command based on the given owner and repository name.