You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gitea/modules
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>
7 months ago
..
actions Resolve lint for unused parameter and unnecessary type arguments (#30750) 9 months ago
activitypub Upgrade to golangci-lint@v1.55.0 (#27756) 1 year ago
analyze Rename code_langauge.go to code_language.go (#26377) 2 years ago
assetfs Use `Set[Type]` instead of `map[Type]bool/struct{}`. (#26804) 1 year ago
auth Add Passkey login support (#31504) 7 months ago
avatar Use `crypto/sha256` (#29386) 11 months ago
badge Implement actions badge svgs (#28102) 11 months ago
base Fix natural sort (#31384) 8 months ago
cache Add cache test for admins (#31265) 8 months ago
charset Render embedded code preview by permlink in markdown (#30234) 10 months ago
container Add container.FilterSlice function (#30339) 10 months ago
csv Render embedded code preview by permlink in markdown (#30234) 10 months ago
dump Refactor "dump" sub-command (#30240) 10 months ago
emoji Update emoji set to Unicode 15 (#25595) 2 years ago
eventsource Final round of `db.DefaultContext` refactor (#27587) 1 year ago
generate Refactor JWT secret generating & decoding code (#29172) 12 months ago
git Fix slow patch checking with commits that add or remove many files (#31548) 7 months ago
gitgraph More `db.DefaultContext` refactor (#27265) 1 year ago
gitrepo Use repo as of renderctx's member rather than a repoPath on metas (#29222) 8 months ago
graceful Remove unused error in graceful manager (#29871) 11 months ago
hcaptcha Consume hcaptcha and pwn deps (#22610) 2 years ago
highlight Add option to disable ambiguous unicode characters detection (#28454) 1 year ago
hostmatcher Support allowed hosts for webhook to work with proxy (#27655) 1 year ago
html Refactor backend SVG package and add tests (#26335) 2 years ago
httpcache Also match weakly validated ETags (#28957) 1 year ago
httplib Fix duplicate sub-path for avatars (#31365) 8 months ago
indexer Fix bug filtering issues which have no project (#31337) 8 months ago
issue/template Support setting the `default` attribute of the issue template dropdown field (#31045) 8 months ago
json Replace `interface{}` with `any` (#25686) 2 years ago
label Make label templates have consistent behavior and priority (#23749) 2 years ago
lfs Support legacy _links LFS batch responses (#31513) 7 months ago
log Add some tests to clarify the "must-change-password" behavior (#30693) 9 months ago
markup Fix markdown preview $$ support (#31514) 7 months ago
mcaptcha Implement FSFE REUSE for golang files (#21840) 2 years ago
metrics Rename project board -> column to make the UI less confusing (#30170) 8 months ago
migration Refactor locale&string&template related code (#29165) 12 months ago
nosql Update tool dependencies, lock govulncheck and actionlint (#25655) 2 years ago
optional Resolve lint for unused parameter and unnecessary type arguments (#30750) 9 months ago
options Use a general approach to access custom/static/builtin assets (#24022) 2 years ago
packages Extract and display readme and comments for Composer packages (#30927) 8 months ago
paginator Use more specific test methods (#24265) 2 years ago
pprof Implement FSFE REUSE for golang files (#21840) 2 years ago
private Move database operations of merging a pull request to post receive hook and add a transaction (#30805) 9 months ago
process Update misspell to 0.5.1 and add `misspellings.csv` (#30573) 9 months ago
proxy Use proxy for pull mirror (#22771) 2 years ago
proxyprotocol Implement FSFE REUSE for golang files (#21840) 2 years ago
public Refactor CORS handler (#28587) 1 year ago
queue Fix queue test (#30646) 9 months ago
recaptcha Implement FSFE REUSE for golang files (#21840) 2 years ago
references Refactor to use UnsafeStringToBytes (#31358) 8 months ago
regexplru Upgrade go dependencies (#25819) 2 years ago
repository Fix adopt repository has empty object name in database (#31333) 8 months ago
secret Use `crypto/sha256` (#29386) 11 months ago
session Improve oauth2 client "preferred username field" logic and the error handling (#30622) 9 months ago
setting Fix duplicate sub-path for avatars (#31365) 8 months ago
sitemap Fix sitemap (#22272) 2 years ago
ssh Remove SSH workaround (#27893) 1 year ago
storage Enable `unparam` linter (#31277) 8 months ago
structs Allow force push to protected branches (#28086) 7 months ago
svg Refactor markdown attention render (#29984) 10 months ago
sync Implement FSFE REUSE for golang files (#21840) 2 years ago
system Refactor to use UnsafeStringToBytes (#31358) 8 months ago
templates Refactor names (#31405) 8 months ago
test Remove sub-path from container registry realm (#31293) 8 months ago
testlogger Replace `interface{}` with `any` (#25686) 2 years ago
timeutil Refactor "dump" sub-command (#30240) 10 months ago
translation Render embedded code preview by permlink in markdown (#30234) 10 months ago
turnstile Add new captcha: cloudflare turnstile (#22369) 2 years ago
typesniffer Detect ogg mime-type as audio or video (#26494) 1 year ago
updatechecker Replace more db.DefaultContext (#27628) 1 year ago
uri Implement FSFE REUSE for golang files (#21840) 2 years ago
user Implement FSFE REUSE for golang files (#21840) 2 years ago
util Refactor to use UnsafeStringToBytes (#31358) 8 months ago
validation Check blocklist for emails when adding them to account (#26812) 1 year ago
web Refactor names (#31405) 8 months ago
webhook Fix schedule tasks bugs (#28691) 1 year ago