0
0
mirror of https://github.com/go-gitea/gitea.git synced 2025-05-28 18:14:47 +02:00

Fix bug when visiting comparation page (#34334) (#34365)

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>
This commit is contained in:
Giteabot 2025-05-05 04:43:42 +08:00 committed by GitHub
parent 16f15d2f7b
commit e4717d426e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 2 additions and 13 deletions

View File

@ -401,12 +401,11 @@ func ParseCompareInfo(ctx *context.Context) *common.CompareInfo {
ci.HeadRepo = ctx.Repo.Repository
ci.HeadGitRepo = ctx.Repo.GitRepo
} else if has {
ci.HeadGitRepo, err = gitrepo.OpenRepository(ctx, ci.HeadRepo)
ci.HeadGitRepo, err = gitrepo.RepositoryFromRequestContextOrOpen(ctx, ci.HeadRepo)
if err != nil {
ctx.ServerError("OpenRepository", err)
ctx.ServerError("RepositoryFromRequestContextOrOpen", err)
return nil
}
defer ci.HeadGitRepo.Close()
} else {
ctx.NotFound(nil)
return nil
@ -721,11 +720,6 @@ func getBranchesAndTagsForRepo(ctx gocontext.Context, repo *repo_model.Repositor
// CompareDiff show different from one commit to another commit
func CompareDiff(ctx *context.Context) {
ci := ParseCompareInfo(ctx)
defer func() {
if ci != nil && ci.HeadGitRepo != nil {
ci.HeadGitRepo.Close()
}
}()
if ctx.Written() {
return
}

View File

@ -1290,11 +1290,6 @@ func CompareAndPullRequestPost(ctx *context.Context) {
)
ci := ParseCompareInfo(ctx)
defer func() {
if ci != nil && ci.HeadGitRepo != nil {
ci.HeadGitRepo.Close()
}
}()
if ctx.Written() {
return
}