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
+9 -9
View File
@@ -76,7 +76,7 @@ func Commits(ctx *context.Context) {
}
// Both `git log branchName` and `git log commitId` work.
commits, err := ctx.Repo.Commit.CommitsByRange(ctx.Repo.GitRepo, page, pageSize, "", "", "")
commits, err := ctx.Repo.Commit.CommitsByRange(ctx, ctx.Repo.GitRepo, page, pageSize, "", "", "")
if err != nil {
ctx.ServerError("CommitsByRange", err)
return
@@ -141,7 +141,7 @@ func Graph(ctx *context.Context) {
page := ctx.FormInt("page")
graph, err := gitgraph.GetCommitGraph(ctx.Repo.GitRepo, page, 0, hidePRRefs, realBranches, files)
graph, err := gitgraph.GetCommitGraph(ctx, ctx.Repo.GitRepo, page, 0, hidePRRefs, realBranches, files)
if err != nil {
ctx.ServerError("GetCommitGraph", err)
return
@@ -154,7 +154,7 @@ func Graph(ctx *context.Context) {
ctx.Data["Graph"] = graph
gitRefs, err := ctx.Repo.GitRepo.GetRefs()
gitRefs, err := ctx.Repo.GitRepo.GetRefs(ctx)
if err != nil {
ctx.ServerError("GitRepo.GetRefs", err)
return
@@ -189,7 +189,7 @@ func SearchCommits(ctx *context.Context) {
all := ctx.FormBool("all")
opts := git.NewSearchCommitsOptions(query, all)
commits, err := ctx.Repo.Commit.SearchCommits(ctx.Repo.GitRepo, opts)
commits, err := ctx.Repo.Commit.SearchCommits(ctx, ctx.Repo.GitRepo, opts)
if err != nil {
ctx.ServerError("SearchCommits", err)
return
@@ -220,7 +220,7 @@ func FileHistory(ctx *context.Context) {
ctx.Data["FollowRenameChecked"] = followRename
page := max(ctx.FormInt("page"), 1)
commits, hasMore, err := ctx.Repo.GitRepo.CommitsByFileAndRange(
commits, hasMore, err := ctx.Repo.GitRepo.CommitsByFileAndRange(ctx,
git.CommitsByFileAndRangeOptions{
Revision: ctx.Repo.RefFullName.ShortName(), // FIXME: legacy code used ShortName
File: ctx.Repo.TreePath,
@@ -302,7 +302,7 @@ func Diff(ctx *context.Context) {
diffBlobExcerptData.BaseLink = ctx.Repo.RepoLink + "/wiki/blob_excerpt"
}
commit, err := gitRepo.GetCommit(commitID)
commit, err := gitRepo.GetCommit(ctx, commitID)
if err != nil {
if git.IsErrNotExist(err) {
ctx.NotFound(err)
@@ -357,7 +357,7 @@ func Diff(ctx *context.Context) {
var parentCommit *git.Commit
var parentCommitID string
if commit.ParentCount() > 0 {
parentCommit, err = gitRepo.GetCommit(parents[0])
parentCommit, err = gitRepo.GetCommit(ctx, parents[0])
if err != nil {
ctx.NotFound(err)
return
@@ -433,7 +433,7 @@ func Diff(ctx *context.Context) {
func RawDiff(ctx *context.Context) {
var gitRepo *git.Repository
if ctx.Data["PageIsWiki"] != nil {
wikiRepo, err := gitrepo.OpenRepository(ctx, ctx.Repo.Repository.WikiStorageRepo())
wikiRepo, err := gitrepo.OpenRepository(ctx.Repo.Repository.WikiStorageRepo())
if err != nil {
ctx.ServerError("OpenRepository", err)
return
@@ -447,7 +447,7 @@ func RawDiff(ctx *context.Context) {
return
}
}
if err := git.GetRawDiff(
if err := git.GetRawDiff(ctx,
gitRepo,
ctx.PathParam("sha"),
git.RawDiffType(ctx.PathParam("ext")),