Skip to content

Commit 089b4e6

Browse files
authored
Use indirect comparison when showing pull requests (#18313)
When generating the commits list and number of files changed for PRs and compare we should use "..." always not "..". Fix #18303 Signed-off-by: Andrew Thornton <art27@cantab.net>
1 parent a7ee4d5 commit 089b4e6

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

Diff for: routers/api/v1/repo/pull.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -1034,7 +1034,7 @@ func parseCompareInfo(ctx *context.APIContext, form api.CreatePullRequestOption)
10341034
return nil, nil, nil, nil, "", ""
10351035
}
10361036

1037-
compareInfo, err := headGitRepo.GetCompareInfo(repo_model.RepoPath(baseRepo.Owner.Name, baseRepo.Name), baseBranch, headBranch, true, false)
1037+
compareInfo, err := headGitRepo.GetCompareInfo(repo_model.RepoPath(baseRepo.Owner.Name, baseRepo.Name), baseBranch, headBranch, false, false)
10381038
if err != nil {
10391039
headGitRepo.Close()
10401040
ctx.Error(http.StatusInternalServerError, "GetCompareInfo", err)
@@ -1211,9 +1211,9 @@ func GetPullRequestCommits(ctx *context.APIContext) {
12111211
}
12121212
defer baseGitRepo.Close()
12131213
if pr.HasMerged {
1214-
prInfo, err = baseGitRepo.GetCompareInfo(pr.BaseRepo.RepoPath(), pr.MergeBase, pr.GetGitRefName(), true, false)
1214+
prInfo, err = baseGitRepo.GetCompareInfo(pr.BaseRepo.RepoPath(), pr.MergeBase, pr.GetGitRefName(), false, false)
12151215
} else {
1216-
prInfo, err = baseGitRepo.GetCompareInfo(pr.BaseRepo.RepoPath(), pr.BaseBranch, pr.GetGitRefName(), true, false)
1216+
prInfo, err = baseGitRepo.GetCompareInfo(pr.BaseRepo.RepoPath(), pr.BaseBranch, pr.GetGitRefName(), false, false)
12171217
}
12181218
if err != nil {
12191219
ctx.ServerError("GetCompareInfo", err)

Diff for: routers/web/repo/pull.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ func PrepareMergedViewPullInfo(ctx *context.Context, issue *models.Issue) *git.C
358358
}
359359

360360
compareInfo, err := ctx.Repo.GitRepo.GetCompareInfo(ctx.Repo.Repository.RepoPath(),
361-
baseCommit, pull.GetGitRefName(), true, false)
361+
baseCommit, pull.GetGitRefName(), false, false)
362362
if err != nil {
363363
if strings.Contains(err.Error(), "fatal: Not a valid object name") || strings.Contains(err.Error(), "unknown revision or path not in the working tree") {
364364
ctx.Data["IsPullRequestBroken"] = true
@@ -441,7 +441,7 @@ func PrepareViewPullInfo(ctx *context.Context, issue *models.Issue) *git.Compare
441441
}
442442

443443
compareInfo, err := baseGitRepo.GetCompareInfo(pull.BaseRepo.RepoPath(),
444-
pull.MergeBase, pull.GetGitRefName(), true, false)
444+
pull.MergeBase, pull.GetGitRefName(), false, false)
445445
if err != nil {
446446
if strings.Contains(err.Error(), "fatal: Not a valid object name") {
447447
ctx.Data["IsPullRequestBroken"] = true
@@ -557,7 +557,7 @@ func PrepareViewPullInfo(ctx *context.Context, issue *models.Issue) *git.Compare
557557
}
558558

559559
compareInfo, err := baseGitRepo.GetCompareInfo(pull.BaseRepo.RepoPath(),
560-
git.BranchPrefix+pull.BaseBranch, pull.GetGitRefName(), true, false)
560+
git.BranchPrefix+pull.BaseBranch, pull.GetGitRefName(), false, false)
561561
if err != nil {
562562
if strings.Contains(err.Error(), "fatal: Not a valid object name") {
563563
ctx.Data["IsPullRequestBroken"] = true

Diff for: services/pull/pull.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ func NewPullRequest(repo *repo_model.Repository, pull *models.Issue, labelIDs []
8282
defer baseGitRepo.Close()
8383

8484
compareInfo, err := baseGitRepo.GetCompareInfo(pr.BaseRepo.RepoPath(),
85-
git.BranchPrefix+pr.BaseBranch, pr.GetGitRefName(), true, false)
85+
git.BranchPrefix+pr.BaseBranch, pr.GetGitRefName(), false, false)
8686
if err != nil {
8787
return err
8888
}

0 commit comments

Comments
 (0)