Always show owner/repo name in compare page dropdowns#37172
Conversation
There was a problem hiding this comment.
Pull request overview
Updates the compare page branch selector labels so they consistently display owner/repo instead of sometimes showing only the owner name.
Changes:
- Build
$BaseCompareNameand$HeadCompareNameunconditionally asowner/repo. - Build
$OwnForkCompareNameand$RootRepoCompareNameasowner/repowhen those repos are present. - Remove prior conditional logic that only sometimes upgraded head display names.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Good change imho. Better to show owner all the time. This is consistent with GitHub too, but they have separate dropdown for owner which Gitea currently does not have, so it's fine given the current design. In the future, we should implement separate dropdown like GitHub. |
|
Could you please adjust the pr description? Its somehow destroyed |
|
@bircni I just adjusted the PR description |
|
Hi @GiteaBot I wanted to kindly ask if you might have time to take a look at this PR when convenient. I’d really appreciate any feedback or suggestions you may have. Thank you for your time and for maintaining the project! |
|
Giteabot is just a bot he won't respond 😊 |
|
Hello @bircni Thank you for your time and for maintaining the project! |
bircni
left a comment
There was a problem hiding this comment.
PR description needs to be adjusted after @wxiaoguang s fix
|
@bircni And one question: I'm seeing above message on my PR. |
Per default mergers and toc can push to your branch, when "allow maintainers to push" is active for your pr |
|
@bircni , Thank you for your answer 😉 |
Fixes: go-gitea#36677 --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Backport #37172 by @xingxing21 Fixes: #36677 The fix is a template-only change in [templates/repo/diff/compare.tmpl:16-25](vscode-webview://1ca9j6f1e3qtaf59o0cr4ind65ulf8mevvbbbq88int1gg2lncar/templates/repo/diff/compare.tmpl#L16-L25). Before, the display names were built with conditional logic: All four variables defaulted to just the owner name (Examples) $HeadCompareName was only upgraded to owner/repo format in two narrow cases: Same org, different repos A root repo exists with the same owner as the head repo All other cases (same-repo PRs, cross-org PRs) got owner-only labels After, all four variables are unconditionally set to owner/repo format using printf "%s/%s": ``` - {{$BaseCompareName := printf "%s/%s" $.BaseName $.Repository.Name -}} - {{- $HeadCompareName := printf "%s/%s" $.HeadRepo.OwnerName $.HeadRepo.Name -}} - {{- $OwnForkCompareName := "" -}} - {{- if .OwnForkRepo -}} - {{- $OwnForkCompareName = printf "%s/%s" .OwnForkRepo.OwnerName .OwnForkRepo.Name -}} - {{- end -}} - {{- $RootRepoCompareName := "" -}} - {{- if .RootRepo -}} - {{- $RootRepoCompareName = printf "%s/%s" .RootRepo.OwnerName .RootRepo.Name -}} - {{- end -}} + {{$BaseCompareName := $.Repository.FullName -}} + {{$HeadCompareName := $.HeadRepo.FullName -}} + {{$OwnForkCompareName := "" -}} + {{if $.OwnForkRepo -}} + {{$OwnForkCompareName = $.OwnForkRepo.FullName -}} + {{end -}} + {{$RootRepoCompareName := "" -}} + {{if $.RootRepo -}} + {{$RootRepoCompareName = $.RootRepo.FullName -}} + {{end -}} ``` These variables drive the labels in the base and head branch selector buttons and their dropdown items. No backend changes were needed — $.BaseName, $.Repository.Name, $.HeadRepo.OwnerName, and $.HeadRepo.Name were already available in the template context. Co-authored-by: Xing Hong <39619359+xingxing21@users.noreply.github.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* main: Add comment for the design of "user activity time" (go-gitea#37195) fix(api): handle missing base branch in PR commits API (go-gitea#37193) Refactor htmx and fetch-action related code (go-gitea#37186) Fix encoding for Matrix Webhooks (go-gitea#37190) Always show owner/repo name in compare page dropdowns (go-gitea#37172) fix(api): handle fork-only commits in compare API (go-gitea#37185) Improve Contributing docs and set a release schedule (go-gitea#37109) Update Nix flake (go-gitea#37183) Remove outdated RunUser logic (go-gitea#37180) Refactor flash message and remove SanitizeHTML template func (go-gitea#37179) Indicate form field readonly via background (go-gitea#37175) Remove dead CSS rules (go-gitea#37173) Fix flaky `TestCatFileBatch/QueryTerminated` test (go-gitea#37159) Implement logout redirection for reverse proxy auth setups (go-gitea#36085) Add missing `//nolint:depguard` (go-gitea#37162)
Fixes: #36677
The fix is a template-only change in templates/repo/diff/compare.tmpl:16-25.
Before, the display names were built with conditional logic:
All four variables defaulted to just the owner name (Examples)
$HeadCompareName was only upgraded to owner/repo format in two narrow cases:
Same org, different repos
A root repo exists with the same owner as the head repo
All other cases (same-repo PRs, cross-org PRs) got owner-only labels
After, all four variables are unconditionally set to owner/repo format using printf "%s/%s":
These variables drive the labels in the base and head branch selector buttons and their dropdown items. No backend changes were needed —$.BaseName, $ .Repository.Name, $.HeadRepo.OwnerName, and $ .HeadRepo.Name were already available in the template context.