Skip to content

Commit 8e5aa8f

Browse files
GiteaBotlunny
andauthored
Fix bug when visiting comparation page (#34334) (#34364)
Backport #34334 by @lunny The `ci.HeadGitRepo` was opened and closed in the function `ParseCompareInfo` but reused in the function `PrepareCompareDiff`. --------- Co-authored-by: Lunny Xiao <[email protected]>
1 parent 046fc86 commit 8e5aa8f

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

routers/web/repo/compare.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,6 @@ func ParseCompareInfo(ctx *context.Context) *common.CompareInfo {
405405
ctx.ServerError("OpenRepository", err)
406406
return nil
407407
}
408-
defer ci.HeadGitRepo.Close()
409408
} else {
410409
ctx.NotFound("ParseCompareInfo", nil)
411410
return nil
@@ -708,7 +707,7 @@ func getBranchesAndTagsForRepo(ctx gocontext.Context, repo *repo_model.Repositor
708707
func CompareDiff(ctx *context.Context) {
709708
ci := ParseCompareInfo(ctx)
710709
defer func() {
711-
if ci != nil && ci.HeadGitRepo != nil {
710+
if !ctx.Repo.PullRequest.SameRepo && ci != nil && ci.HeadGitRepo != nil {
712711
ci.HeadGitRepo.Close()
713712
}
714713
}()

routers/web/repo/pull.go

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

12641264
ci := ParseCompareInfo(ctx)
12651265
defer func() {
1266-
if ci != nil && ci.HeadGitRepo != nil {
1266+
if !ctx.Repo.PullRequest.SameRepo && ci != nil && ci.HeadGitRepo != nil {
12671267
ci.HeadGitRepo.Close()
12681268
}
12691269
}()

0 commit comments

Comments
 (0)