Skip to content

Conversation

@lunny
Copy link
Member

@lunny lunny commented Jan 27, 2026

Fix #36390

Sometimes the compare will include diff but not commit.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Jan 27, 2026
@github-actions github-actions bot added modifies/go Pull requests that update Go code modifies/templates This PR modifies the template files labels Jan 27, 2026
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Jan 27, 2026
@wxiaoguang wxiaoguang marked this pull request as draft January 27, 2026 16:39
<div class="ui container fluid padded tw-my-4">
{{template "repo/commits_table" .}}
{{template "repo/diff/box" .}}
{{if .CommitCount}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a bug where the compare button in the PR timeline would incorrectly show "These branches are equal" when a commit is dropped via force push, even though there is actually a diff to display.

Changes:

  • Renamed IsNothingToCompare to DiffNotAvailable to better reflect the semantic meaning
  • Updated template logic to show the diff section when either commits exist OR a diff is available (not just when commits exist)
  • Added comprehensive integration test to validate the fix for the force push scenario

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
routers/web/repo/compare.go Sets both CommitCount=0 and DiffNotAvailable=true when comparing identical commits; maintains existing logic for determining when diff is unavailable
routers/web/repo/pull.go Renames IsNothingToCompare to DiffNotAvailable for consistency
templates/repo/diff/compare.tmpl Updates conditional logic to show diff section when commits exist OR diff is available, and conditionally displays commits table and diff box separately
templates/repo/commits_table.tmpl Updates variable reference from IsNothingToCompare to DiffNotAvailable
tests/integration/pull_compare_test.go Adds test that reproduces the bug by creating a PR, force-pushing to drop a commit, and verifying the compare link shows the diff

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


if compareInfo.HeadCommitID == compareInfo.MergeBase {
ctx.Data["IsNothingToCompare"] = true
ctx.Data["DiffNotAvailable"] = true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not right.

<div class="ui container fluid padded tw-my-4">
{{template "repo/commits_table" .}}
{{template "repo/diff/box" .}}
{{if $hasCommits}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not right

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport/v1.25 lgtm/need 1 This PR needs approval from one additional maintainer to be merged. modifies/go Pull requests that update Go code modifies/templates This PR modifies the template files type/bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Compare Button in PR Timeline Shows Empty Result When Dropping a Commit

4 participants