0
0
mirror of https://github.com/go-gitea/gitea.git synced 2026-05-11 09:15:31 +02:00

add group id to file comparison urls

This commit is contained in:
☙◦ The Tablet ❀ GamerGirlandCo ◦❧ 2025-11-25 22:37:51 -05:00
parent 7187abcd3e
commit ee6783625c
No known key found for this signature in database
GPG Key ID: 924A5F6AF051E87C
3 changed files with 24 additions and 14 deletions

View File

@ -265,6 +265,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{
@ -348,7 +349,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.MessageTitle() + " · " + base.ShortSha(commitID)
ctx.Data["Commit"] = commit
ctx.Data["Diff"] = diff

View File

@ -7,6 +7,7 @@ import (
gocontext "context"
"encoding/csv"
"errors"
"fmt"
"io"
"net/http"
"net/url"
@ -52,7 +53,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
@ -83,28 +84,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)
}
}
@ -523,7 +532,7 @@ func (cpi *comparePageInfoType) prepareCompareDiff(ctx *context.Context, whitesp
ctx.Data["title"], ctx.Data["content"] = prepareNewPullRequestTitleContent(ci, commits, setting.Repository.PullRequest.DefaultTitleSource)
setCompareContext(ctx, beforeCommit, headCommit, ci.HeadRepo.OwnerName, repo.Name)
setCompareContext(ctx, beforeCommit, headCommit, ci.HeadRepo.OwnerName, repo.Name, repo.GroupID)
}
func getBranchesAndTagsForRepo(ctx gocontext.Context, repo *repo_model.Repository) (branches, tags []string, err error) {

View File

@ -857,7 +857,7 @@ func viewPullFiles(ctx *context.Context, beforeCommitID, afterCommitID string) {
return
}
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 {