From 4e68d6f41d21e7c5465be6bdb6713c36eb586dfd Mon Sep 17 00:00:00 2001 From: Marty <58218546+PotatoesFall@users.noreply.github.com> Date: Thu, 29 Jul 2021 04:32:48 +0200 Subject: [PATCH] Show correct text when comparing commits on empty pull request (#16569) * fix * use own text * Update templates/repo/commits_table.tmpl Co-authored-by: marty Co-authored-by: zeripath --- options/locale/locale_en-US.ini | 1 + routers/web/repo/pull.go | 4 ++++ templates/repo/commits_table.tmpl | 3 +++ 3 files changed, 8 insertions(+) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 760c026116..96fda97dda 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -1040,6 +1040,7 @@ editor.require_signed_commit = Branch requires a signed commit commits.desc = Browse source code change history. commits.commits = Commits commits.no_commits = No commits in common. '%s' and '%s' have entirely different histories. +commits.nothing_to_compare = These branches are equal. commits.search = Search commits… commits.search.tooltip = You can prefix keywords with "author:", "committer:", "after:", or "before:", e.g. "revert author:Alice before:2019-04-01". commits.find = Search diff --git a/routers/web/repo/pull.go b/routers/web/repo/pull.go index 15c9f14808..5c61e0d5fa 100644 --- a/routers/web/repo/pull.go +++ b/routers/web/repo/pull.go @@ -527,6 +527,10 @@ func PrepareViewPullInfo(ctx *context.Context, issue *models.Issue) *git.Compare return nil } + if compareInfo.HeadCommitID == compareInfo.MergeBase { + ctx.Data["IsNothingToCompare"] = true + } + ctx.Data["PullRequestWorkInProgressPrefixes"] = setting.Repository.PullRequest.WorkInProgressPrefixes if pull.IsWorkInProgress() { diff --git a/templates/repo/commits_table.tmpl b/templates/repo/commits_table.tmpl index 3ef2339843..7bdcb340d9 100644 --- a/templates/repo/commits_table.tmpl +++ b/templates/repo/commits_table.tmpl @@ -2,6 +2,9 @@
{{if or .PageIsCommits (gt .CommitCount 0)}} {{.CommitCount}} {{.i18n.Tr "repo.commits.commits"}} {{if .Branch}}({{.Branch}}){{end}} + {{else if .IsNothingToCompare }} + {{.i18n.Tr "repo.commits.nothing_to_compare" }} {{if .Branch}}({{.Branch}}){{end}} + {{else}} {{.i18n.Tr "repo.commits.no_commits" $.BaseBranch $.HeadBranch }} {{if .Branch}}({{.Branch}}){{end}} {{end}}