gitea/templates
Henry Goodman 12cb1d2998
Allow force push to protected branches (#28086)
Fixes #22722 

### Problem
Currently, it is not possible to force push to a branch with branch
protection rules in place. There are often times where this is necessary
(CI workflows/administrative tasks etc).

The current workaround is to rename/remove the branch protection,
perform the force push, and then reinstate the protections.

### Solution
Provide an additional section in the branch protection rules to allow
users to specify which users with push access can also force push to the
branch. The default value of the rule will be set to `Disabled`, and the
UI is intuitive and very similar to the `Push` section.

It is worth noting in this implementation that allowing force push does
not override regular push access, and both will need to be enabled for a
user to force push.

This applies to manual force push to a remote, and also in Gitea UI
updating a PR by rebase (which requires force push)

This modifies the `BranchProtection` API structs to add:
- `enable_force_push bool`
- `enable_force_push_whitelist bool`
- `force_push_whitelist_usernames string[]`
- `force_push_whitelist_teams string[]`
- `force_push_whitelist_deploy_keys bool`

### Updated Branch Protection UI:

<img width="943" alt="image"
src="https://github.com/go-gitea/gitea/assets/79623665/7491899c-d816-45d5-be84-8512abd156bf">

### Pull Request `Update branch by Rebase` option enabled with source
branch `test` being a protected branch:


![image](https://github.com/go-gitea/gitea/assets/79623665/e018e6e9-b7b2-4bd3-808e-4947d7da35cc)
<img width="1038" alt="image"
src="https://github.com/go-gitea/gitea/assets/79623665/57ead13e-9006-459f-b83c-7079e6f4c654">

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2024-07-05 18:21:56 +00:00
..
admin Add cache test for admins (#31265) 2024-06-17 21:22:39 +02:00
api/packages/pypi Fix links in PyPI Simple Repository API page (#30594) 2024-04-20 01:15:14 +00:00
base Refactor repo unit "disabled" check (#31389) 2024-06-18 00:51:13 +00:00
custom
devtest Make toast support preventDuplicates (#31501) 2024-06-27 13:58:38 +00:00
explore
mail
org Right align the "Settings" menu item in overflow-menu (#30764) 2024-04-30 04:26:13 +00:00
package Extract and display readme and comments for Composer packages (#30927) 2024-06-14 04:45:52 +00:00
projects Replace gt-word-break with tw-break-anywhere (#31183) 2024-06-04 13:57:11 +00:00
repo Allow force push to protected branches (#28086) 2024-07-05 18:21:56 +00:00
shared Improve detecting empty files (#31332) 2024-06-13 01:06:46 +00:00
status Simplify 404/500 page (#31409) 2024-06-23 17:45:21 +00:00
swagger Allow force push to protected branches (#28086) 2024-07-05 18:21:56 +00:00
user Refactor login page (#31530) 2024-07-05 20:10:09 +03:00
webhook
home.tmpl
install.tmpl Fix some UI problems (install/checkbox) (#30854) 2024-05-06 06:32:05 +00:00
post-install.tmpl