From de290f21214252ea2d5f534992a4ecfe34d28223 Mon Sep 17 00:00:00 2001 From: Nicolas Date: Mon, 11 May 2026 18:28:44 +0200 Subject: [PATCH] fix(templates): avoid misleading compare message when branches lack merge base (#37651) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary When comparing branches with **no common merge base** (e.g. unrelated histories or orphan branches), `PageIsComparePull` is false and `CommitCount` is zero. The compare template still showed `repo.commits.nothing_to_compare`, which in German reads like the branches are identical—even though the flash already explains there is no merge base. ## Changes - **`templates/repo/diff/compare.tmpl`**: Only render the grey “nothing to compare” segment when `CompareInfo.CompareBase` is set. Fixes #37642 --------- Signed-off-by: Nicolas --- options/locale/locale_en-US.json | 6 +++--- templates/repo/diff/compare.tmpl | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/options/locale/locale_en-US.json b/options/locale/locale_en-US.json index a0c2e086ef..e6248944e7 100644 --- a/options/locale/locale_en-US.json +++ b/options/locale/locale_en-US.json @@ -1321,7 +1321,7 @@ "repo.commits.desc": "Browse source code change history.", "repo.commits.commits": "Commits", "repo.commits.no_commits": "No commits in common. \"%s\" and \"%s\" have entirely different histories.", - "repo.commits.nothing_to_compare": "These branches are equal.", + "repo.commits.nothing_to_compare": "There are no differences to show.", "repo.commits.search.tooltip": "You can prefix keywords with \"author:\", \"committer:\", \"after:\", or \"before:\", e.g. \"revert author:Alice before:2019-01-13\".", "repo.commits.search_branch": "This Branch", "repo.commits.search_all": "All Branches", @@ -1783,9 +1783,9 @@ "repo.pulls.select_commit_hold_shift_for_range": "Select commit. Hold Shift and click to select a range.", "repo.pulls.review_only_possible_for_full_diff": "Review is only possible when viewing the full diff", "repo.pulls.filter_changes_by_commit": "Filter by commit", - "repo.pulls.nothing_to_compare": "These branches are equal. There is no need to create a pull request.", + "repo.pulls.nothing_to_compare": "There are no differences to show. There is no need to create a pull request.", "repo.pulls.no_common_history": "These branches do not share a common merge base. Select a different base or compare branch.", - "repo.pulls.nothing_to_compare_have_tag": "The selected branches/tags are equal.", + "repo.pulls.nothing_to_compare_have_tag": "There are no differences to show between the selected branches or tags.", "repo.pulls.nothing_to_compare_and_allow_empty_pr": "These branches are equal. This PR will be empty.", "repo.pulls.has_pull_request": "A pull request between these branches already exists: %[2]s#%[3]d", "repo.pulls.create": "Create Pull Request", diff --git a/templates/repo/diff/compare.tmpl b/templates/repo/diff/compare.tmpl index 9ed4b73174..9572715ac3 100644 --- a/templates/repo/diff/compare.tmpl +++ b/templates/repo/diff/compare.tmpl @@ -210,8 +210,8 @@ {{template "repo/issue/new_form" .}} {{end}} - {{else}}{{/* not singed-in or not for pull-request */}} - {{if not .CommitCount}} + {{else}}{{/* not signed-in or not for pull-request */}} + {{if and (not .CommitCount) $.CompareInfo.CompareBase}}
{{ctx.Locale.Tr "repo.commits.nothing_to_compare"}}
{{end}} {{end}}