@@ -54,7 +54,7 @@ const (
5454)
5555
5656// setCompareContext sets context data.
57- func setCompareContext (ctx * context.Context , before , head * git.Commit , headOwner , headName string ) {
57+ func setCompareContext (ctx * context.Context , before , head * git.Commit , headOwner , headName string , headGID int64 ) {
5858 ctx .Data ["BeforeCommit" ] = before
5959 ctx .Data ["HeadCommit" ] = head
6060
@@ -85,28 +85,36 @@ func setCompareContext(ctx *context.Context, before, head *git.Commit, headOwner
8585 return st
8686 }
8787
88- setPathsCompareContext (ctx , before , head , headOwner , headName )
88+ setPathsCompareContext (ctx , before , head , headOwner , headName , headGID )
8989 setImageCompareContext (ctx )
9090 setCsvCompareContext (ctx )
9191}
9292
9393// SourceCommitURL creates a relative URL for a commit in the given repository
94- func SourceCommitURL (owner , name string , commit * git.Commit ) string {
95- return setting .AppSubURL + "/" + url .PathEscape (owner ) + "/" + url .PathEscape (name ) + "/src/commit/" + url .PathEscape (commit .ID .String ())
94+ func SourceCommitURL (owner , name string , gid int64 , commit * git.Commit ) string {
95+ var groupSegment string
96+ if gid > 0 {
97+ groupSegment = fmt .Sprintf ("group/%d/" , gid )
98+ }
99+ return setting .AppSubURL + "/" + url .PathEscape (owner ) + "/" + groupSegment + url .PathEscape (name ) + "/src/commit/" + url .PathEscape (commit .ID .String ())
96100}
97101
98102// RawCommitURL creates a relative URL for the raw commit in the given repository
99- func RawCommitURL (owner , name string , commit * git.Commit ) string {
100- return setting .AppSubURL + "/" + url .PathEscape (owner ) + "/" + url .PathEscape (name ) + "/raw/commit/" + url .PathEscape (commit .ID .String ())
103+ func RawCommitURL (owner , name string , gid int64 , commit * git.Commit ) string {
104+ var groupSegment string
105+ if gid > 0 {
106+ groupSegment = fmt .Sprintf ("group/%d/" , gid )
107+ }
108+ return setting .AppSubURL + "/" + url .PathEscape (owner ) + "/" + groupSegment + url .PathEscape (name ) + "/raw/commit/" + url .PathEscape (commit .ID .String ())
101109}
102110
103111// setPathsCompareContext sets context data for source and raw paths
104- func setPathsCompareContext (ctx * context.Context , base , head * git.Commit , headOwner , headName string ) {
105- ctx .Data ["SourcePath" ] = SourceCommitURL (headOwner , headName , head )
106- ctx .Data ["RawPath" ] = RawCommitURL (headOwner , headName , head )
112+ func setPathsCompareContext (ctx * context.Context , base , head * git.Commit , headOwner , headName string , headGID int64 ) {
113+ ctx .Data ["SourcePath" ] = SourceCommitURL (headOwner , headName , headGID , head )
114+ ctx .Data ["RawPath" ] = RawCommitURL (headOwner , headName , headGID , head )
107115 if base != nil {
108- ctx .Data ["BeforeSourcePath" ] = SourceCommitURL (headOwner , headName , base )
109- ctx .Data ["BeforeRawPath" ] = RawCommitURL (headOwner , headName , base )
116+ ctx .Data ["BeforeSourcePath" ] = SourceCommitURL (headOwner , headName , headGID , base )
117+ ctx .Data ["BeforeRawPath" ] = RawCommitURL (headOwner , headName , headGID , base )
110118 }
111119}
112120
@@ -718,7 +726,7 @@ func PrepareCompareDiff(
718726 ctx .Data ["Username" ] = ci .HeadUser .Name
719727 ctx .Data ["Reponame" ] = ci .HeadRepo .Name
720728
721- setCompareContext (ctx , beforeCommit , headCommit , ci .HeadUser .Name , repo .Name )
729+ setCompareContext (ctx , beforeCommit , headCommit , ci .HeadUser .Name , repo .Name , repo . GroupID )
722730
723731 return false
724732}
0 commit comments