feat: Add block on pending codeowner reviews branch protection (#34995)

This commit introduces a new branch protection rule that allows merge
blocking if there are pending reviews from one or more code owners (as
defined in any valid `CODEOWNERS` file). This is determined by
evaluating each rule present in the `CODEOWNERS` file individually. For
every rule, at least one named code owner (or member of a code owner
team) must have given an approving review for merging to be possible.

Closes #32602 

---

This PR does NOT display code owners separately from other reviewers
(#28137)

### Screenshot

<details>
<summary>Pull Request</summary>
<img
src="https://github.com/user-attachments/assets/74560f9c-9f59-477a-b270-63f937b26d6a"
/>
</details>

<details>
<summary>Branch Protection Rule</summary>
<img
src="https://github.com/user-attachments/assets/f0a9ce00-38fe-4eed-b6a3-5290aa404610"
/>
</details>

Doc PR
https://gitea.com/gitea/docs/pulls/245

---------

Signed-off-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: bircni <bircni@icloud.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
Dominique Hummel
2026-07-31 13:00:59 +00:00
committed by GitHub
co-authored by bircni wxiaoguang
parent 805697089e
commit 1f6cfe611a
17 changed files with 408 additions and 41 deletions
+3
View File
@@ -1830,6 +1830,7 @@
"repo.pulls.blocked_by_outdated_branch": "This pull request is blocked because it's outdated.",
"repo.pulls.blocked_by_changed_protected_files_1": "This pull request is blocked because it changes a protected file:",
"repo.pulls.blocked_by_changed_protected_files_n": "This pull request is blocked because it changes protected files:",
"repo.pulls.blocked_by_codeowners": "This pull request is missing approval from one or more code owners.",
"repo.pulls.can_auto_merge_desc": "This pull request can be merged automatically.",
"repo.pulls.cannot_auto_merge_desc": "This pull request cannot be merged automatically due to conflicts.",
"repo.pulls.cannot_auto_merge_helper": "Merge manually to resolve the conflicts.",
@@ -2463,6 +2464,8 @@
"repo.settings.block_on_official_review_requests_desc": "Merging will not be possible when it has official review requests, even if there are enough approvals.",
"repo.settings.block_outdated_branch": "Block merge if pull request is outdated",
"repo.settings.block_outdated_branch_desc": "Merging will not be possible when head branch is behind base branch.",
"repo.settings.block_on_codeowner_reviews": "Require approval from code owners",
"repo.settings.block_on_codeowner_reviews_desc": "Merging will only be possible if at least one code owner per code owner rule has given an approving review.",
"repo.settings.block_admin_merge_override": "Administrators must follow branch protection rules",
"repo.settings.block_admin_merge_override_desc": "Administrators must follow branch protection rules and cannot circumvent it. Users or teams in the bypass allowlist can still bypass these rules if bypass allowlist is enabled.",
"repo.settings.default_branch_desc": "Select a default branch for code commits.",