1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-03 09:07:19 +00:00

Repare and Improve GetDiffRangeWithWhitespaceBehavior (#16894) (#16895)

fix pipe leak
This commit is contained in:
6543
2021-08-31 05:02:27 +02:00
committed by GitHub
parent 49a71a6461
commit c54639b8ee
5 changed files with 26 additions and 37 deletions

View File

@ -587,10 +587,9 @@ func ViewPullFiles(ctx *context.Context) {
pull := issue.PullRequest
var (
diffRepoPath string
startCommitID string
endCommitID string
gitRepo *git.Repository
gitRepo = ctx.Repo.GitRepo
)
var prInfo *git.CompareInfo
@ -607,9 +606,6 @@ func ViewPullFiles(ctx *context.Context) {
return
}
diffRepoPath = ctx.Repo.GitRepo.Path
gitRepo = ctx.Repo.GitRepo
headCommitID, err := gitRepo.GetRefCommitID(pull.GetGitRefName())
if err != nil {
ctx.ServerError("GetRefCommitID", err)
@ -623,7 +619,7 @@ func ViewPullFiles(ctx *context.Context) {
ctx.Data["Reponame"] = ctx.Repo.Repository.Name
ctx.Data["AfterCommitID"] = endCommitID
diff, err := gitdiff.GetDiffRangeWithWhitespaceBehavior(diffRepoPath,
diff, err := gitdiff.GetDiffRangeWithWhitespaceBehavior(gitRepo,
startCommitID, endCommitID, setting.Git.MaxGitDiffLines,
setting.Git.MaxGitDiffLineCharacters, setting.Git.MaxGitDiffFiles,
gitdiff.GetWhitespaceFlag(ctx.Data["WhitespaceBehavior"].(string)))