Skip to content

Commit f1ae24f

Browse files
committed
Fix bug
1 parent 2f07898 commit f1ae24f

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

routers/web/repo/compare.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -400,9 +400,9 @@ func ParseCompareInfo(ctx *context.Context) *common.CompareInfo {
400400
ci.HeadRepo = ctx.Repo.Repository
401401
ci.HeadGitRepo = ctx.Repo.GitRepo
402402
} else if has {
403-
ci.HeadGitRepo, err = gitrepo.RepositoryFromRequestContextOrOpen(ctx, ci.HeadRepo)
403+
ci.HeadGitRepo, err = gitrepo.OpenRepository(ctx, ci.HeadRepo)
404404
if err != nil {
405-
ctx.ServerError("RepositoryFromRequestContextOrOpen", err)
405+
ctx.ServerError("OpenRepository", err)
406406
return nil
407407
}
408408
} else {
@@ -706,6 +706,11 @@ func getBranchesAndTagsForRepo(ctx gocontext.Context, repo *repo_model.Repositor
706706
// CompareDiff show different from one commit to another commit
707707
func CompareDiff(ctx *context.Context) {
708708
ci := ParseCompareInfo(ctx)
709+
defer func() {
710+
if !ctx.Repo.PullRequest.SameRepo && ci != nil && ci.HeadGitRepo != nil {
711+
ci.HeadGitRepo.Close()
712+
}
713+
}()
709714
if ctx.Written() {
710715
return
711716
}

routers/web/repo/pull.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1262,6 +1262,11 @@ func CompareAndPullRequestPost(ctx *context.Context) {
12621262
)
12631263

12641264
ci := ParseCompareInfo(ctx)
1265+
defer func() {
1266+
if !ctx.Repo.PullRequest.SameRepo && ci != nil && ci.HeadGitRepo != nil {
1267+
ci.HeadGitRepo.Close()
1268+
}
1269+
}()
12651270
if ctx.Written() {
12661271
return
12671272
}

0 commit comments

Comments
 (0)