Skip to content

Always show owner/repo name in compare page dropdowns#37172

Merged
wxiaoguang merged 4 commits into
go-gitea:mainfrom
xingxing21:fix/compare-dropdown-repo-name
Apr 13, 2026
Merged

Always show owner/repo name in compare page dropdowns#37172
wxiaoguang merged 4 commits into
go-gitea:mainfrom
xingxing21:fix/compare-dropdown-repo-name

Conversation

@xingxing21
Copy link
Copy Markdown
Contributor

@xingxing21 xingxing21 commented Apr 10, 2026

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":

- {{$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.

Copilot AI review requested due to automatic review settings April 10, 2026 16:52
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Apr 10, 2026
Copy link
Copy Markdown
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

Updates the compare page branch selector labels so they consistently display owner/repo instead of sometimes showing only the owner name.

Changes:

  • Build $BaseCompareName and $HeadCompareName unconditionally as owner/repo.
  • Build $OwnForkCompareName and $RootRepoCompareName as owner/repo when 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.

@silverwind
Copy link
Copy Markdown
Member

silverwind commented Apr 11, 2026

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.

@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 Apr 11, 2026
@silverwind silverwind changed the title #36677 Fix compare page dropdowns always showing owner/repo name Always show owner/repo name in compare page dropdowns Apr 11, 2026
@bircni
Copy link
Copy Markdown
Member

bircni commented Apr 11, 2026

Could you please adjust the pr description? Its somehow destroyed

@xingxing21
Copy link
Copy Markdown
Contributor Author

@bircni I just adjusted the PR description

@xingxing21
Copy link
Copy Markdown
Contributor Author

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!

@bircni
Copy link
Copy Markdown
Member

bircni commented Apr 13, 2026

Giteabot is just a bot he won't respond 😊

@xingxing21
Copy link
Copy Markdown
Contributor Author

Hello @bircni
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!

Copy link
Copy Markdown
Member

@bircni bircni left a comment

Choose a reason for hiding this comment

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

PR description needs to be adjusted after @wxiaoguang s fix

@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Apr 13, 2026
@xingxing21
Copy link
Copy Markdown
Contributor Author

@bircni
I just changed the description after @wxiaoguang s fix
Thanks!

And one question:

Merging is blocked
You're not authorized to push to this branch. Visit https://docs.github.com/repositories/configuring-branches-and-merges-in-your-repository/managing-protected-branches/about-protected-branches for more information.

I'm seeing above message on my PR.
How can I authorize to push to this branch?

@bircni
Copy link
Copy Markdown
Member

bircni commented Apr 13, 2026

And one question:

Merging is blocked
You're not authorized to push to this branch. Visit https://docs.github.com/repositories/configuring-branches-and-merges-in-your-repository/managing-protected-branches/about-protected-branches for more information.

I'm seeing above message on my PR. How can I authorize to push to this branch?

Per default mergers and toc can push to your branch, when "allow maintainers to push" is active for your pr
You see this as you are not allowed to merge this to main - thats why there is this "You're not authorized to push to this branch. "

@xingxing21
Copy link
Copy Markdown
Contributor Author

@bircni , Thank you for your answer 😉

@wxiaoguang wxiaoguang merged commit fa8f7f1 into go-gitea:main Apr 13, 2026
26 checks passed
@GiteaBot GiteaBot added this to the 1.27.0 milestone Apr 13, 2026
@wxiaoguang wxiaoguang added the backport/v1.26 This PR should be backported to Gitea 1.26 label Apr 13, 2026
GiteaBot pushed a commit to GiteaBot/gitea that referenced this pull request Apr 13, 2026
Fixes: go-gitea#36677

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
@GiteaBot GiteaBot added the backport/done All backports for this PR have been created label Apr 13, 2026
silverwind pushed a commit that referenced this pull request Apr 13, 2026
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>
zjjhot added a commit to zjjhot/gitea that referenced this pull request Apr 14, 2026
* 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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport/done All backports for this PR have been created backport/v1.26 This PR should be backported to Gitea 1.26 lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Repository Names are suddenly missing in drop down menus for Pull Requests

6 participants