Skip to content

Commit bcc6f9d

Browse files
add group id segment to repository's Link method
1 parent f6466c8 commit bcc6f9d

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

models/repo/repo.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,7 @@ func (repo *Repository) RepoPath() string {
628628

629629
// Link returns the repository relative url
630630
func (repo *Repository) Link() string {
631-
return setting.AppSubURL + "/" + url.PathEscape(repo.OwnerName) + "/" + url.PathEscape(repo.Name)
631+
return setting.AppSubURL + "/" + url.PathEscape(repo.OwnerName) + "/" + groupSegmentWithTrailingSlash(repo.GroupID) + url.PathEscape(repo.Name)
632632
}
633633

634634
// ComposeCompareURL returns the repository comparison URL
@@ -699,7 +699,7 @@ type CloneLink struct {
699699
func getGroupSegment(gid int64) string {
700700
var groupSegment string
701701
if gid > 0 {
702-
groupSegment = fmt.Sprintf("%d", gid)
702+
groupSegment = fmt.Sprintf("group/%d", gid)
703703
}
704704
return groupSegment
705705
}
@@ -733,7 +733,7 @@ func ComposeSSHCloneURL(doer *user_model.User, ownerName, repoName string, group
733733
// non-standard port, it must use full URI
734734
if setting.SSH.Port != 22 {
735735
sshHost := net.JoinHostPort(sshDomain, strconv.Itoa(setting.SSH.Port))
736-
return fmt.Sprintf("ssh://%s@%s/%s%s/%s.git", sshUser, sshHost, url.PathEscape(ownerName), groupSegmentWithTrailingSlash(groupID), url.PathEscape(repoName))
736+
return fmt.Sprintf("ssh://%s@%s/%s/%s%s.git", sshUser, sshHost, url.PathEscape(ownerName), groupSegmentWithTrailingSlash(groupID), url.PathEscape(repoName))
737737
}
738738

739739
// for standard port, it can use a shorter URI (without the port)
@@ -742,9 +742,9 @@ func ComposeSSHCloneURL(doer *user_model.User, ownerName, repoName string, group
742742
sshHost = "[" + sshHost + "]" // for IPv6 address, wrap it with brackets
743743
}
744744
if setting.Repository.UseCompatSSHURI {
745-
return fmt.Sprintf("ssh://%s@%s/%s/%s.git", sshUser, sshHost, url.PathEscape(ownerName), url.PathEscape(repoName))
745+
return fmt.Sprintf("ssh://%s@%s/%s/%s%s.git", sshUser, sshHost, url.PathEscape(ownerName), groupSegmentWithTrailingSlash(groupID), url.PathEscape(repoName))
746746
}
747-
return fmt.Sprintf("%s@%s:%s/%s.git", sshUser, sshHost, url.PathEscape(ownerName), url.PathEscape(repoName))
747+
return fmt.Sprintf("%s@%s:%s/%s%s.git", sshUser, sshHost, url.PathEscape(ownerName), groupSegmentWithTrailingSlash(groupID), url.PathEscape(repoName))
748748
}
749749

750750
// ComposeTeaCloneCommand returns Tea CLI clone command based on the given owner and repository name.

0 commit comments

Comments
 (0)