refactor: remove Ctx field from git.Repository (#38500)

This commit is contained in:
wxiaoguang
2026-07-17 18:44:31 +08:00
committed by GitHub
parent 2c8e99bbf7
commit 5b078f72aa
235 changed files with 1234 additions and 1258 deletions
+7 -7
View File
@@ -203,7 +203,7 @@ func GetPullDiffStats(ctx *context.Context) {
}
// do not report 500 server error to end users if error occurs, otherwise a PR missing ref won't be able to view.
headCommitID, err := ctx.Repo.GitRepo.GetRefCommitID(pull.GetGitHeadRefName())
headCommitID, err := ctx.Repo.GitRepo.GetRefCommitID(ctx, pull.GetGitHeadRefName())
if errors.Is(err, util.ErrNotExist) {
return
} else if err != nil {
@@ -227,7 +227,7 @@ func GetMergedBaseCommitID(ctx *context.Context, issue *issues_model.Issue) stri
if pull.MergeBase == "" {
var commitSHA, parentCommit string
// If there is a head or a patch file, and it is readable, grab info
commitSHA, err := ctx.Repo.GitRepo.GetRefCommitID(pull.GetGitHeadRefName())
commitSHA, err := ctx.Repo.GitRepo.GetRefCommitID(ctx, pull.GetGitHeadRefName())
if err != nil {
// Head File does not exist, try the patch
commitSHA, err = ctx.Repo.GitRepo.ReadPatchCommit(pull.Index)
@@ -555,13 +555,13 @@ func getViewPullHeadBranchCommitID(ctx *context.Context, pull *issues_model.Pull
if err != nil {
return "", err
}
return headGitRepo.GetRefCommitID(git.RefNameFromBranch(pull.HeadBranch).String())
return headGitRepo.GetRefCommitID(ctx, git.RefNameFromBranch(pull.HeadBranch).String())
case issues_model.PullRequestFlowAGit:
baseGitRepo, err := gitrepo.RepositoryFromRequestContextOrOpen(ctx, pull.BaseRepo)
if err != nil {
return "", err
}
return baseGitRepo.GetRefCommitID(pull.GetGitHeadRefName())
return baseGitRepo.GetRefCommitID(ctx, pull.GetGitHeadRefName())
}
setting.PanicInDevOrTesting("invalid pull request flow type: %v", pull.Flow)
return "", util.ErrNotExist
@@ -731,7 +731,7 @@ func viewPullFiles(ctx *context.Context, beforeCommitID, afterCommitID string) {
afterCommitID = util.IfZero(afterCommitID, headCommitID)
afterCommit := indexCommit(prCompareInfo.Commits, afterCommitID)
if afterCommit == nil && afterCommitID == headCommitID {
afterCommit, err = gitRepo.GetCommit(afterCommitID)
afterCommit, err = gitRepo.GetCommit(ctx, afterCommitID)
if err != nil {
ctx.ServerError("GetCommit(afterCommitID)", err)
return
@@ -744,7 +744,7 @@ func viewPullFiles(ctx *context.Context, beforeCommitID, afterCommitID string) {
var beforeCommit *git.Commit
if isSingleCommit {
beforeCommit, err = afterCommit.Parent(ctx.Repo.GitRepo, 0)
beforeCommit, err = afterCommit.Parent(ctx, ctx.Repo.GitRepo, 0)
if err != nil {
ctx.ServerError("afterCommit.Parent", err)
return
@@ -755,7 +755,7 @@ func viewPullFiles(ctx *context.Context, beforeCommitID, afterCommitID string) {
beforeCommit = indexCommit(prCompareInfo.Commits, beforeCommitID)
if beforeCommit == nil && beforeCommitID == prCompareInfo.CompareBase {
// base commit is not in the list of the pull request commits
beforeCommit, err = gitRepo.GetCommit(beforeCommitID)
beforeCommit, err = gitRepo.GetCommit(ctx, beforeCommitID)
if err != nil {
ctx.ServerError("GetCommit(beforeCommitID)", err)
return