Skip to content

Commit e6bd151

Browse files
committed
improve
1 parent e1d49da commit e6bd151

File tree

2 files changed

+2
-14
lines changed

2 files changed

+2
-14
lines changed

routers/web/repo/compare.go

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -402,12 +402,11 @@ func ParseCompareInfo(ctx *context.Context) *common.CompareInfo {
402402
ci.HeadRepo = ctx.Repo.Repository
403403
ci.HeadGitRepo = ctx.Repo.GitRepo
404404
} else if has {
405-
ci.HeadGitRepo, err = gitrepo.OpenRepository(ctx, ci.HeadRepo)
405+
ci.HeadGitRepo, err = gitrepo.RepositoryFromRequestContextOrOpen(ctx, ci.HeadRepo)
406406
if err != nil {
407-
ctx.ServerError("OpenRepository", err)
407+
ctx.ServerError("RepositoryFromRequestContextOrOpen", err)
408408
return nil
409409
}
410-
// if it's not the same git repo, the HeadGitRepo should be closed out of the function
411410
} else {
412411
ctx.NotFound(nil)
413412
return nil
@@ -726,12 +725,6 @@ func getBranchesAndTagsForRepo(ctx gocontext.Context, repo *repo_model.Repositor
726725
// CompareDiff show different from one commit to another commit
727726
func CompareDiff(ctx *context.Context) {
728727
ci := ParseCompareInfo(ctx)
729-
defer func() {
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 {
732-
ci.HeadGitRepo.Close()
733-
}
734-
}()
735728
if ctx.Written() {
736729
return
737730
}

routers/web/repo/pull.go

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

12981298
ci := ParseCompareInfo(ctx)
1299-
defer func() {
1300-
if !ctx.Repo.PullRequest.SameRepo && ci != nil && ci.HeadGitRepo != nil {
1301-
ci.HeadGitRepo.Close()
1302-
}
1303-
}()
13041299
if ctx.Written() {
13051300
return
13061301
}

0 commit comments

Comments
 (0)