gitea/templates/repo/settings
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
..
webhook Prevent tab shifting, remove extra margin on fluid pages (#31090) 2024-05-27 06:45:16 +00:00
actions.tmpl Support configuration variables on Gitea Actions (#24724) 2023-06-20 22:54:15 +00:00
branches.tmpl Migrate margin and padding helpers to tailwind (#30043) 2024-03-24 17:42:49 +01:00
collaboration.tmpl use correct l10n string (#31487) 2024-06-25 14:54:18 +00:00
deploy_keys.tmpl template: label fix correct input id (#30987) 2024-05-16 14:36:31 +08:00
githook_edit.tmpl Migrate gt-hidden to tw-hidden (#30046) 2024-03-24 18:23:38 +00:00
githooks.tmpl Migrate margin and padding helpers to tailwind (#30043) 2024-03-24 17:42:49 +01:00
layout_footer.tmpl Change to vertical navbar layout for secondary navbar for repo/user/admin settings (#24246) 2023-04-23 18:21:21 +08:00
layout_head.tmpl Use flex-container for repo and org settings (#27418) 2023-10-04 08:47:54 +02:00
lfs_file_find.tmpl Remove RenderEmojiPlain from template helper (#29375) 2024-02-24 22:34:51 +00:00
lfs_file.tmpl Improve detecting empty files (#31332) 2024-06-13 01:06:46 +00:00
lfs_locks.tmpl Fix more "locale" usages (#27259) 2023-09-25 20:42:40 +08:00
lfs_pointers.tmpl code optimization (#31315) 2024-06-11 21:07:10 +08:00
lfs.tmpl Remove fomantic button module (#30475) 2024-04-14 17:53:52 +00:00
navbar.tmpl Refactor repo unit "disabled" check (#31389) 2024-06-18 00:51:13 +00:00
options.tmpl Replace gt-word-break with tw-break-anywhere (#31183) 2024-06-04 13:57:11 +00:00
protected_branch.tmpl Allow force push to protected branches (#28086) 2024-07-05 18:21:56 +00:00
push_mirror_sync_modal.tmpl Always use ctx.Locale.Tr inside templates (#27231) 2023-09-25 08:56:50 +00:00
runner_edit.tmpl Change to vertical navbar layout for secondary navbar for repo/user/admin settings (#24246) 2023-04-23 18:21:21 +08:00
secrets.tmpl Change to vertical navbar layout for secondary navbar for repo/user/admin settings (#24246) 2023-04-23 18:21:21 +08:00
tags.tmpl Replace 10 more gt- classes with tw- (#29945) 2024-03-22 13:45:10 +00:00