-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
Fix bug when comparing there is diff but no commit #36460
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
templates/repo/diff/compare.tmpl
Outdated
| <div class="ui container fluid padded tw-my-4"> | ||
| {{template "repo/commits_table" .}} | ||
| {{template "repo/diff/box" .}} | ||
| {{if .CommitCount}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this 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
IsNothingToComparetoDiffNotAvailableto 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 |
There was a problem hiding this comment.
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}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not right
Fix #36390
Sometimes the compare will include diff but not commit.