Skip to content
/ gitea Public
  • Sponsor go-gitea/gitea

  • Notifications You must be signed in to change notification settings
  • Fork 5.8k
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 465a8f5

Browse files
committedMay 1, 2025··
Fix bug
1 parent b5c9f43 commit 465a8f5

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed
 

‎routers/web/repo/compare.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ func ParseCompareInfo(ctx *context.Context) *common.CompareInfo {
407407
ctx.ServerError("OpenRepository", err)
408408
return nil
409409
}
410-
defer ci.HeadGitRepo.Close()
410+
// if it's not the same git repo, the HeadGitRepo should be closed out of the function
411411
} else {
412412
ctx.NotFound(nil)
413413
return nil
@@ -727,7 +727,8 @@ func getBranchesAndTagsForRepo(ctx gocontext.Context, repo *repo_model.Repositor
727727
func CompareDiff(ctx *context.Context) {
728728
ci := ParseCompareInfo(ctx)
729729
defer func() {
730-
if ci != nil && ci.HeadGitRepo != nil {
730+
// If it's the same repo, the git repo should be managed by the context
731+
if !ctx.Repo.PullRequest.SameRepo && ci != nil && ci.HeadGitRepo != nil {
731732
ci.HeadGitRepo.Close()
732733
}
733734
}()

‎routers/web/repo/pull.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1297,7 +1297,7 @@ func CompareAndPullRequestPost(ctx *context.Context) {
12971297

12981298
ci := ParseCompareInfo(ctx)
12991299
defer func() {
1300-
if ci != nil && ci.HeadGitRepo != nil {
1300+
if !ctx.Repo.PullRequest.SameRepo && ci != nil && ci.HeadGitRepo != nil {
13011301
ci.HeadGitRepo.Close()
13021302
}
13031303
}()

0 commit comments

Comments
 (0)
Please sign in to comment.