Skip to content

Also display "recently pushed branch" alert on PR view #35001

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

Merged
merged 5 commits into from
Jul 10, 2025

Conversation

Naxdy
Copy link
Contributor

@Naxdy Naxdy commented Jul 8, 2025

This commit adds the "You recently pushed to branch X" alert also to PR overview, as opposed to only the repository's home page.

GitHub also shows this alert on the PR list, as well as the home page, which makes sense, since a common flow is:

  1. Go to issues page
  2. Grab an issue to work on
  3. Branch off
  4. Work
  5. Push
  6. Open PR

For step 6, many devs' intuition is to go directly to the pull request page, to open a new PR. However, in current Gitea, this is actually not optimal, since this would require you to enter your PR details manually, and going to the home page would let you take a shortcut, which is unintuitive.


Screenshots:

PR List:

image

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Jul 8, 2025
@github-actions github-actions bot added modifies/go Pull requests that update Go code modifies/templates This PR modifies the template files labels Jul 8, 2025
@lunny lunny added the type/enhancement An improvement of existing functionality label Jul 8, 2025
@lunny lunny added this to the 1.25.0 milestone Jul 8, 2025
@silverwind
Copy link
Member

But GH does not show it on the issues page right? Why should we?

@Naxdy
Copy link
Contributor Author

Naxdy commented Jul 8, 2025

My thought was mainly because of time tracking. So if you work on something, then go to stop your time tracking, you have the alert close by. I have no strong feelings towards that part however.

@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 Jul 8, 2025
@Naxdy Naxdy force-pushed the work/pr-on-pr-view branch from c3fa987 to 07db743 Compare July 8, 2025 18:39
@silverwind
Copy link
Member

Maybe keep it to the PR page. Issue page with issue pins visible would be quite overloaded imho.

@wxiaoguang
Copy link
Contributor

Two things in my mind:

  1. Please keep the function in "route" related packages
  2. Please don't show the banner on the "issue list" page

@Naxdy Naxdy force-pushed the work/pr-on-pr-view branch from 07db743 to 5ba8849 Compare July 9, 2025 06:25
@Naxdy Naxdy changed the title Display "new pull request" alert also on issue & PR lists Also display "recently pushed branch" alert on PR view Jul 9, 2025
@Naxdy
Copy link
Contributor Author

Naxdy commented Jul 9, 2025

Changed it to only show on the PR page due to popular demand, and also moved the file back to routers/utils.

@Naxdy Naxdy requested a review from lunny July 9, 2025 09:09
@silverwind
Copy link
Member

silverwind commented Jul 9, 2025

We can show it on the repo homepage though, example from GitHub:

image

BTW I wish there was a way to never show these messages for certain branches, like our release/v1.24 which is a release branch and not meant to be pulled into main.

@Naxdy
Copy link
Contributor Author

Naxdy commented Jul 9, 2025

We can show it on the repo homepage though, example from GitHub:

This is the current behavior, which I didn't change. Sorry if I made it seem like I removed that functionality in favor of having it only on the PR view, that's not the case! :)

@silverwind
Copy link
Member

silverwind commented Jul 9, 2025

Ah I wasn't aware. So we show it on:

  • Frontpage
  • Repo Homepage
  • Pull Requests List (with this PR)

Is that correct?

@Naxdy
Copy link
Contributor Author

Naxdy commented Jul 9, 2025

Yep, that covers it!

@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 Jul 9, 2025
@wxiaoguang wxiaoguang marked this pull request as draft July 10, 2025 01:04
@wxiaoguang
Copy link
Contributor

wxiaoguang commented Jul 10, 2025

Thank you very much for the PR. Your change is good enough. I made some more changes, some ideas are:

  • Move the code from "route/utils" package to "route/repo" package
    • By reading other code in "route/utils" package, it seems that "util" is more suitable for some functions to "help"
    • Our prepareRecentlyPushedNewBranches prepares the template rendering data, so "route/repo" seems more suitable
  • Introduce repo.CanContentChange to replace IsMirror check
    • That's a more complete check for whether a repo is changeable
    • I found the problem when working on other PRs, now it seems a good chance to introduce it and make prepareRecentlyPushedNewBranches better
  • Introduce a dedicated struct to pass "RecentBranchesPromptData"
    • Golang template is quite fragile, so if there is a chance, I'd like to clearly define the variable name and struct, to make it less fragile.
    • And no need to use the if PageIsPull check, now the template only renders when there is "RecentBranchesPromptData"
  • Fine tune the template and simplify the tw-xx helpers

So I made some changes that I'd like to do sooner or later in this PR together 😆 🙏

Screenshot (no visual change):

image

image

image

@wxiaoguang wxiaoguang marked this pull request as ready for review July 10, 2025 01:47
@lunny lunny added the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Jul 10, 2025
@wxiaoguang wxiaoguang enabled auto-merge (squash) July 10, 2025 16:45
@wxiaoguang wxiaoguang merged commit 32152a0 into go-gitea:main Jul 10, 2025
26 checks passed
@GiteaBot GiteaBot removed the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Jul 10, 2025
zjjhot added a commit to zjjhot/gitea that referenced this pull request Jul 11, 2025
* giteaofficial/main:
  Fix updating user visibility (go-gitea#35036)
  Fix git commit committer parsing and add some tests (go-gitea#35007)
  Refactor OpenIDConnect to support SSH/FullName sync (go-gitea#34978)
  Support base64-encoded agit push options (go-gitea#35037)
  Also display "recently pushed branch" alert on PR view (go-gitea#35001)
  Make submodule link work with relative path (go-gitea#35034)
  Update to go 1.24.5 (go-gitea#35031)
  Improve CLI commands (go-gitea#34973)
  Tweak eslint config, fix new issues (go-gitea#35019)

# Conflicts:
#	templates/repo/commits_list.tmpl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. modifies/go Pull requests that update Go code modifies/templates This PR modifies the template files type/enhancement An improvement of existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants