mirror of
https://github.com/go-gitea/gitea.git
synced 2026-04-04 07:55:31 +02:00
add group id to file comparison urls
This commit is contained in:
parent
139a681f0e
commit
2443ea0fd9
@ -275,6 +275,7 @@ func Diff(ctx *context.Context) {
|
||||
|
||||
userName := ctx.Repo.Owner.Name
|
||||
repoName := ctx.Repo.Repository.Name
|
||||
repoGroup := ctx.Repo.Repository.GroupID
|
||||
commitID := ctx.PathParam("sha")
|
||||
|
||||
diffBlobExcerptData := &gitdiff.DiffBlobExcerptData{
|
||||
@ -360,7 +361,7 @@ func Diff(ctx *context.Context) {
|
||||
}
|
||||
parentCommitID = parentCommit.ID.String()
|
||||
}
|
||||
setCompareContext(ctx, parentCommit, commit, userName, repoName)
|
||||
setCompareContext(ctx, parentCommit, commit, userName, repoName, repoGroup)
|
||||
ctx.Data["Title"] = commit.Summary() + " · " + base.ShortSha(commitID)
|
||||
ctx.Data["Commit"] = commit
|
||||
ctx.Data["Diff"] = diff
|
||||
|
||||
@ -7,6 +7,7 @@ import (
|
||||
gocontext "context"
|
||||
"encoding/csv"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/url"
|
||||
@ -51,7 +52,7 @@ const (
|
||||
)
|
||||
|
||||
// setCompareContext sets context data.
|
||||
func setCompareContext(ctx *context.Context, before, head *git.Commit, headOwner, headName string) {
|
||||
func setCompareContext(ctx *context.Context, before, head *git.Commit, headOwner, headName string, headGID int64) {
|
||||
ctx.Data["BeforeCommit"] = before
|
||||
ctx.Data["HeadCommit"] = head
|
||||
|
||||
@ -82,28 +83,36 @@ func setCompareContext(ctx *context.Context, before, head *git.Commit, headOwner
|
||||
return st
|
||||
}
|
||||
|
||||
setPathsCompareContext(ctx, before, head, headOwner, headName)
|
||||
setPathsCompareContext(ctx, before, head, headOwner, headName, headGID)
|
||||
setImageCompareContext(ctx)
|
||||
setCsvCompareContext(ctx)
|
||||
}
|
||||
|
||||
// SourceCommitURL creates a relative URL for a commit in the given repository
|
||||
func SourceCommitURL(owner, name string, commit *git.Commit) string {
|
||||
return setting.AppSubURL + "/" + url.PathEscape(owner) + "/" + url.PathEscape(name) + "/src/commit/" + url.PathEscape(commit.ID.String())
|
||||
func SourceCommitURL(owner, name string, gid int64, commit *git.Commit) string {
|
||||
var groupSegment string
|
||||
if gid > 0 {
|
||||
groupSegment = fmt.Sprintf("group/%d/", gid)
|
||||
}
|
||||
return setting.AppSubURL + "/" + url.PathEscape(owner) + "/" + groupSegment + url.PathEscape(name) + "/src/commit/" + url.PathEscape(commit.ID.String())
|
||||
}
|
||||
|
||||
// RawCommitURL creates a relative URL for the raw commit in the given repository
|
||||
func RawCommitURL(owner, name string, commit *git.Commit) string {
|
||||
return setting.AppSubURL + "/" + url.PathEscape(owner) + "/" + url.PathEscape(name) + "/raw/commit/" + url.PathEscape(commit.ID.String())
|
||||
func RawCommitURL(owner, name string, gid int64, commit *git.Commit) string {
|
||||
var groupSegment string
|
||||
if gid > 0 {
|
||||
groupSegment = fmt.Sprintf("group/%d/", gid)
|
||||
}
|
||||
return setting.AppSubURL + "/" + url.PathEscape(owner) + "/" + groupSegment + url.PathEscape(name) + "/raw/commit/" + url.PathEscape(commit.ID.String())
|
||||
}
|
||||
|
||||
// setPathsCompareContext sets context data for source and raw paths
|
||||
func setPathsCompareContext(ctx *context.Context, base, head *git.Commit, headOwner, headName string) {
|
||||
ctx.Data["SourcePath"] = SourceCommitURL(headOwner, headName, head)
|
||||
ctx.Data["RawPath"] = RawCommitURL(headOwner, headName, head)
|
||||
func setPathsCompareContext(ctx *context.Context, base, head *git.Commit, headOwner, headName string, headGID int64) {
|
||||
ctx.Data["SourcePath"] = SourceCommitURL(headOwner, headName, headGID, head)
|
||||
ctx.Data["RawPath"] = RawCommitURL(headOwner, headName, headGID, head)
|
||||
if base != nil {
|
||||
ctx.Data["BeforeSourcePath"] = SourceCommitURL(headOwner, headName, base)
|
||||
ctx.Data["BeforeRawPath"] = RawCommitURL(headOwner, headName, base)
|
||||
ctx.Data["BeforeSourcePath"] = SourceCommitURL(headOwner, headName, headGID, base)
|
||||
ctx.Data["BeforeRawPath"] = RawCommitURL(headOwner, headName, headGID, base)
|
||||
}
|
||||
}
|
||||
|
||||
@ -572,7 +581,7 @@ func PrepareCompareDiff(
|
||||
ctx.Data["Username"] = ci.HeadRepo.OwnerName
|
||||
ctx.Data["Reponame"] = ci.HeadRepo.Name
|
||||
|
||||
setCompareContext(ctx, beforeCommit, headCommit, ci.HeadRepo.OwnerName, repo.Name)
|
||||
setCompareContext(ctx, beforeCommit, headCommit, ci.HeadRepo.OwnerName, repo.Name, repo.GroupID)
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
@ -906,7 +906,7 @@ func viewPullFiles(ctx *context.Context, beforeCommitID, afterCommitID string) {
|
||||
}
|
||||
}
|
||||
|
||||
setCompareContext(ctx, beforeCommit, afterCommit, ctx.Repo.Owner.Name, ctx.Repo.Repository.Name)
|
||||
setCompareContext(ctx, beforeCommit, afterCommit, ctx.Repo.Owner.Name, ctx.Repo.Repository.Name, ctx.Repo.Repository.GroupID)
|
||||
|
||||
assigneeUsers, err := repo_model.GetRepoAssignees(ctx, ctx.Repo.Repository)
|
||||
if err != nil {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user