Automatic Deletion of Unprotected branches on PR merge with toggleable switch #6312

Closed
opened 2025-11-02 06:52:16 -06:00 by GiteaMirror · 9 comments
Owner

Originally created by @iarepandemonium on GitHub (Nov 14, 2020).

  • Gitea version (or commit ref): 1.14.0+dev-208-g6280af032
  • Git version: 2.29.0
  • Operating system: Linux Ubuntu 16.04
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No (not a bug.)
  • Log gist:

Description

  • Toggleable switch at project level for use
  • if an unprotected branch is merged while switch is set to true, that branch gets deleted
  • protected branches are unaffected

Screenshots

Originally created by @iarepandemonium on GitHub (Nov 14, 2020). - Gitea version (or commit ref): 1.14.0+dev-208-g6280af032 - Git version: 2.29.0 - Operating system: Linux Ubuntu 16.04 - Database (use `[x]`): - [ ] PostgreSQL - [x] MySQL - [ ] MSSQL - [ ] SQLite - Can you reproduce the bug at https://try.gitea.io: - [ ] Yes (provide example URL) - [x] No (not a bug.) - Log gist: ## Description * Toggleable switch at project level for use * if an **unprotected** branch is merged while switch is set to true, that branch gets deleted * protected branches are unaffected ## Screenshots
GiteaMirror added the type/proposal label 2025-11-02 06:52:16 -06:00
Author
Owner

@6543 commented on GitHub (Nov 14, 2020):

similar #3905

@6543 commented on GitHub (Nov 14, 2020): similar #3905
Author
Owner

@6543 commented on GitHub (Nov 14, 2020):

I think merge option will get to overloaded, should we make this a user and/or repo setting?

@6543 commented on GitHub (Nov 14, 2020): I think merge option will get to overloaded, should we make this a user and/or repo setting?
Author
Owner

@iarepandemonium commented on GitHub (Nov 14, 2020):

Yes I intended it to be togglable in the repo's own settings. I don't user repos that often, I considered one at organization level, because I will be personally enabling them in most of our projects but figured it would be too annoying to have 3 options of 'organization default', on, off

@iarepandemonium commented on GitHub (Nov 14, 2020): Yes I intended it to be togglable in the repo's own settings. I don't user repos that often, I considered one at organization level, because I will be personally enabling them in most of our projects but figured it would be too annoying to have 3 options of 'organization default', on, off
Author
Owner

@lunny commented on GitHub (Nov 16, 2020):

Assume the situations:

  • The branch is a default branch on the same repository, send PRs from default branch to non-default branch.
  • The branch is a default branch on the forked repository.
  • The branch on forked repository has also been sent to another upstream and one PR merged but another not.
  • There are also some PRs sent to the forked repository branch. I sent a PR from the branch of my forked repositories to original, and another forked repositories sent a PR to the branch. Then before I merge the PR on my forked repositories, the PR I sent to upstream has been merged.
@lunny commented on GitHub (Nov 16, 2020): Assume the situations: - [ ] The branch is a default branch on the same repository, send PRs from default branch to non-default branch. - [ ] The branch is a default branch on the forked repository. - [ ] The branch on forked repository has also been sent to another upstream and one PR merged but another not. - [ ] There are also some PRs sent to the forked repository branch. I sent a PR from the branch of my forked repositories to original, and another forked repositories sent a PR to the branch. Then before I merge the PR on my forked repositories, the PR I sent to upstream has been merged.
Author
Owner

@lunny commented on GitHub (Mar 6, 2021):

@lunny Can't forked repositories change the fork repo settings? I would have thought so…

@delvh You can, but if you have many forks, you may have to change every repository. Since the fork repositories is your copy of original repositories, so the settings depends on your personal usage habit.

@lunny commented on GitHub (Mar 6, 2021): > @lunny Can't forked repositories change the fork repo settings? I would have thought so… @delvh You can, but if you have many forks, you may have to change every repository. Since the fork repositories is your copy of original repositories, so the settings depends on your personal usage habit.
Author
Owner

@jpraet commented on GitHub (May 25, 2021):

A checkbox like this on the merge form could already be an easy win. Even if it would be disabled by default, at least it saves you from scrolling down to the bottom of the page, clicking the delete branch button and the confirmation dialog. And it serves as a reminder too.

afbeelding

@jpraet commented on GitHub (May 25, 2021): A checkbox like this on the merge form could already be an easy win. Even if it would be disabled by default, at least it saves you from scrolling down to the bottom of the page, clicking the delete branch button and the confirmation dialog. And it serves as a reminder too. ![afbeelding](https://user-images.githubusercontent.com/2212615/119569640-505b0180-bdaf-11eb-9b5b-e19cd67840f6.png)
Author
Owner

@lunny commented on GitHub (Jun 1, 2021):

A checkbox like this on the merge form could already be an easy win. Even if it would be disabled by default, at least it saves you from scrolling down to the bottom of the page, clicking the delete branch button and the confirmation dialog. And it serves as a reminder too.

afbeelding

Maybe the text could be Delete head branch if not protected or default.

@lunny commented on GitHub (Jun 1, 2021): > A checkbox like this on the merge form could already be an easy win. Even if it would be disabled by default, at least it saves you from scrolling down to the bottom of the page, clicking the delete branch button and the confirmation dialog. And it serves as a reminder too. > > ![afbeelding](https://user-images.githubusercontent.com/2212615/119569640-505b0180-bdaf-11eb-9b5b-e19cd67840f6.png) Maybe the text could be `Delete head branch if not protected or default`.
Author
Owner

@6543 commented on GitHub (Jun 1, 2021):

I would prefere @jpraet way but hide it if the branch is protected ...

@6543 commented on GitHub (Jun 1, 2021): I would prefere @jpraet way but hide it if the branch is protected ...
Author
Owner

@lunny commented on GitHub (Jun 2, 2021):

Or disable the checkbox and display the reason

@lunny commented on GitHub (Jun 2, 2021): Or disable the checkbox and display the reason
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#6312