Move updateref and removeref to gitrepo and remove unnecessary open repository (#35511)

Extracted from #35077
`UpdateRef` and `RemoveRef` will call git commands even for gogit
version.
This commit is contained in:
Lunny Xiao
2025-09-19 08:04:18 -07:00
committed by GitHub
parent 9a0ec53ee3
commit 198f37e33c
11 changed files with 46 additions and 47 deletions

View File

@@ -979,7 +979,7 @@ func DeleteIssue(ctx *context.APIContext) {
return
}
if err = issue_service.DeleteIssue(ctx, ctx.Doer, ctx.Repo.GitRepo, issue); err != nil {
if err = issue_service.DeleteIssue(ctx, ctx.Doer, issue); err != nil {
ctx.APIErrorInternal(err)
return
}

View File

@@ -398,7 +398,7 @@ func BatchDeleteIssues(ctx *context.Context) {
return
}
for _, issue := range issues {
if err := issue_service.DeleteIssue(ctx, ctx.Doer, ctx.Repo.GitRepo, issue); err != nil {
if err := issue_service.DeleteIssue(ctx, ctx.Doer, issue); err != nil {
ctx.ServerError("DeleteIssue", err)
return
}

View File

@@ -216,7 +216,7 @@ func DeleteIssue(ctx *context.Context) {
return
}
if err := issue_service.DeleteIssue(ctx, ctx.Doer, ctx.Repo.GitRepo, issue); err != nil {
if err := issue_service.DeleteIssue(ctx, ctx.Doer, issue); err != nil {
ctx.ServerError("DeleteIssueByID", err)
return
}

View File

@@ -224,7 +224,7 @@ func GetMergedBaseCommitID(ctx *context.Context, issue *issues_model.Issue) stri
commitSHA, err = ctx.Repo.GitRepo.ReadPatchCommit(pull.Index)
if err == nil {
// Recreate pull head in files for next time
if err := ctx.Repo.GitRepo.SetReference(pull.GetGitHeadRefName(), commitSHA); err != nil {
if err := gitrepo.UpdateRef(ctx, ctx.Repo.Repository, pull.GetGitHeadRefName(), commitSHA); err != nil {
log.Error("Could not write head file", err)
}
} else {