aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGiteabot <teabot@gitea.io>2025-05-05 03:56:47 +0800
committerGitHub <noreply@github.com>2025-05-04 19:56:47 +0000
commit8e5aa8fb1e0a11a5a0815c2d759f4da80f203cb0 (patch)
tree82a8eaa5c310ae0de9fa2b9b4040bfc483e36ffc
parent046fc8684cc97b6f6192dfb484e84e646588b052 (diff)
downloadgitea-8e5aa8fb1e0a11a5a0815c2d759f4da80f203cb0.tar.gz
gitea-8e5aa8fb1e0a11a5a0815c2d759f4da80f203cb0.zip
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 <xiaolunwen@gmail.com>
-rw-r--r--routers/web/repo/compare.go3
-rw-r--r--routers/web/repo/pull.go2
2 files changed, 2 insertions, 3 deletions
diff --git a/routers/web/repo/compare.go b/routers/web/repo/compare.go
index 278974bec3..9d241d3b51 100644
--- a/routers/web/repo/compare.go
+++ b/routers/web/repo/compare.go
@@ -405,7 +405,6 @@ func ParseCompareInfo(ctx *context.Context) *common.CompareInfo {
ctx.ServerError("OpenRepository", err)
return nil
}
- defer ci.HeadGitRepo.Close()
} else {
ctx.NotFound("ParseCompareInfo", nil)
return nil
@@ -708,7 +707,7 @@ func getBranchesAndTagsForRepo(ctx gocontext.Context, repo *repo_model.Repositor
func CompareDiff(ctx *context.Context) {
ci := ParseCompareInfo(ctx)
defer func() {
- if ci != nil && ci.HeadGitRepo != nil {
+ if !ctx.Repo.PullRequest.SameRepo && ci != nil && ci.HeadGitRepo != nil {
ci.HeadGitRepo.Close()
}
}()
diff --git a/routers/web/repo/pull.go b/routers/web/repo/pull.go
index e068ac45c6..ac08bf2a4f 100644
--- a/routers/web/repo/pull.go
+++ b/routers/web/repo/pull.go
@@ -1263,7 +1263,7 @@ func CompareAndPullRequestPost(ctx *context.Context) {
ci := ParseCompareInfo(ctx)
defer func() {
- if ci != nil && ci.HeadGitRepo != nil {
+ if !ctx.Repo.PullRequest.SameRepo && ci != nil && ci.HeadGitRepo != nil {
ci.HeadGitRepo.Close()
}
}()