Skip to content

Commit cf43ef0

Browse files
add group id segment to repository's Link method
1 parent b83a32f commit cf43ef0

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
@@ -622,7 +622,7 @@ func (repo *Repository) RepoPath() string {
622622

623623
// Link returns the repository relative url
624624
func (repo *Repository) Link() string {
625-
return setting.AppSubURL + "/" + url.PathEscape(repo.OwnerName) + "/" + url.PathEscape(repo.Name)
625+
return setting.AppSubURL + "/" + url.PathEscape(repo.OwnerName) + "/" + groupSegmentWithTrailingSlash(repo.GroupID) + url.PathEscape(repo.Name)
626626
}
627627

628628
// ComposeCompareURL returns the repository comparison URL
@@ -693,7 +693,7 @@ type CloneLink struct {
693693
func getGroupSegment(gid int64) string {
694694
var groupSegment string
695695
if gid > 0 {
696-
groupSegment = fmt.Sprintf("%d", gid)
696+
groupSegment = fmt.Sprintf("group/%d", gid)
697697
}
698698
return groupSegment
699699
}
@@ -727,7 +727,7 @@ func ComposeSSHCloneURL(doer *user_model.User, ownerName, repoName string, group
727727
// non-standard port, it must use full URI
728728
if setting.SSH.Port != 22 {
729729
sshHost := net.JoinHostPort(sshDomain, strconv.Itoa(setting.SSH.Port))
730-
return fmt.Sprintf("ssh://%s@%s/%s%s/%s.git", sshUser, sshHost, url.PathEscape(ownerName), groupSegmentWithTrailingSlash(groupID), url.PathEscape(repoName))
730+
return fmt.Sprintf("ssh://%s@%s/%s/%s%s.git", sshUser, sshHost, url.PathEscape(ownerName), groupSegmentWithTrailingSlash(groupID), url.PathEscape(repoName))
731731
}
732732

733733
// for standard port, it can use a shorter URI (without the port)
@@ -736,9 +736,9 @@ func ComposeSSHCloneURL(doer *user_model.User, ownerName, repoName string, group
736736
sshHost = "[" + sshHost + "]" // for IPv6 address, wrap it with brackets
737737
}
738738
if setting.Repository.UseCompatSSHURI {
739-
return fmt.Sprintf("ssh://%s@%s/%s/%s.git", sshUser, sshHost, url.PathEscape(ownerName), url.PathEscape(repoName))
739+
return fmt.Sprintf("ssh://%s@%s/%s/%s%s.git", sshUser, sshHost, url.PathEscape(ownerName), groupSegmentWithTrailingSlash(groupID), url.PathEscape(repoName))
740740
}
741-
return fmt.Sprintf("%s@%s:%s/%s.git", sshUser, sshHost, url.PathEscape(ownerName), url.PathEscape(repoName))
741+
return fmt.Sprintf("%s@%s:%s/%s%s.git", sshUser, sshHost, url.PathEscape(ownerName), groupSegmentWithTrailingSlash(groupID), url.PathEscape(repoName))
742742
}
743743

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

0 commit comments

Comments
 (0)