From 089b4e6a4585a3d9d185abd9350e7c5d537cfa86 Mon Sep 17 00:00:00 2001 From: zeripath Date: Tue, 18 Jan 2022 07:45:43 +0000 Subject: [PATCH] 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 --- routers/api/v1/repo/pull.go | 6 +++--- routers/web/repo/pull.go | 6 +++--- services/pull/pull.go | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/routers/api/v1/repo/pull.go b/routers/api/v1/repo/pull.go index 8297e35a17765..158abd46515f0 100644 --- a/routers/api/v1/repo/pull.go +++ b/routers/api/v1/repo/pull.go @@ -1034,7 +1034,7 @@ func parseCompareInfo(ctx *context.APIContext, form api.CreatePullRequestOption) return nil, nil, nil, nil, "", "" } - compareInfo, err := headGitRepo.GetCompareInfo(repo_model.RepoPath(baseRepo.Owner.Name, baseRepo.Name), baseBranch, headBranch, true, false) + compareInfo, err := headGitRepo.GetCompareInfo(repo_model.RepoPath(baseRepo.Owner.Name, baseRepo.Name), baseBranch, headBranch, false, false) if err != nil { headGitRepo.Close() ctx.Error(http.StatusInternalServerError, "GetCompareInfo", err) @@ -1211,9 +1211,9 @@ func GetPullRequestCommits(ctx *context.APIContext) { } defer baseGitRepo.Close() if pr.HasMerged { - prInfo, err = baseGitRepo.GetCompareInfo(pr.BaseRepo.RepoPath(), pr.MergeBase, pr.GetGitRefName(), true, false) + prInfo, err = baseGitRepo.GetCompareInfo(pr.BaseRepo.RepoPath(), pr.MergeBase, pr.GetGitRefName(), false, false) } else { - prInfo, err = baseGitRepo.GetCompareInfo(pr.BaseRepo.RepoPath(), pr.BaseBranch, pr.GetGitRefName(), true, false) + prInfo, err = baseGitRepo.GetCompareInfo(pr.BaseRepo.RepoPath(), pr.BaseBranch, pr.GetGitRefName(), false, false) } if err != nil { ctx.ServerError("GetCompareInfo", err) diff --git a/routers/web/repo/pull.go b/routers/web/repo/pull.go index 984954b704c10..6e68fd0c6952d 100644 --- a/routers/web/repo/pull.go +++ b/routers/web/repo/pull.go @@ -358,7 +358,7 @@ func PrepareMergedViewPullInfo(ctx *context.Context, issue *models.Issue) *git.C } compareInfo, err := ctx.Repo.GitRepo.GetCompareInfo(ctx.Repo.Repository.RepoPath(), - baseCommit, pull.GetGitRefName(), true, false) + baseCommit, pull.GetGitRefName(), false, false) if err != nil { if strings.Contains(err.Error(), "fatal: Not a valid object name") || strings.Contains(err.Error(), "unknown revision or path not in the working tree") { ctx.Data["IsPullRequestBroken"] = true @@ -441,7 +441,7 @@ func PrepareViewPullInfo(ctx *context.Context, issue *models.Issue) *git.Compare } compareInfo, err := baseGitRepo.GetCompareInfo(pull.BaseRepo.RepoPath(), - pull.MergeBase, pull.GetGitRefName(), true, false) + pull.MergeBase, pull.GetGitRefName(), false, false) if err != nil { if strings.Contains(err.Error(), "fatal: Not a valid object name") { ctx.Data["IsPullRequestBroken"] = true @@ -557,7 +557,7 @@ func PrepareViewPullInfo(ctx *context.Context, issue *models.Issue) *git.Compare } compareInfo, err := baseGitRepo.GetCompareInfo(pull.BaseRepo.RepoPath(), - git.BranchPrefix+pull.BaseBranch, pull.GetGitRefName(), true, false) + git.BranchPrefix+pull.BaseBranch, pull.GetGitRefName(), false, false) if err != nil { if strings.Contains(err.Error(), "fatal: Not a valid object name") { ctx.Data["IsPullRequestBroken"] = true diff --git a/services/pull/pull.go b/services/pull/pull.go index 9103da07f4998..c1844372ea0cc 100644 --- a/services/pull/pull.go +++ b/services/pull/pull.go @@ -82,7 +82,7 @@ func NewPullRequest(repo *repo_model.Repository, pull *models.Issue, labelIDs [] defer baseGitRepo.Close() compareInfo, err := baseGitRepo.GetCompareInfo(pr.BaseRepo.RepoPath(), - git.BranchPrefix+pr.BaseBranch, pr.GetGitRefName(), true, false) + git.BranchPrefix+pr.BaseBranch, pr.GetGitRefName(), false, false) if err != nil { return err }