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
@@ -362,6 +362,13 @@
<p class="help">{{ctx.Locale.Tr "repo.settings.block_on_official_review_requests_desc"}}</p>
</div>
</div>
<div class="field">
<div class="ui checkbox">
<input name="block_on_codeowner_reviews" type="checkbox" {{if .Rule.BlockOnCodeownerReviews}}checked{{end}}>
<label>{{ctx.Locale.Tr "repo.settings.block_on_codeowner_reviews"}}</label>
<p class="help">{{ctx.Locale.Tr "repo.settings.block_on_codeowner_reviews_desc"}}</p>
</div>
</div>
<div class="field">
<div class="ui checkbox">
<input name="block_on_outdated_branch" type="checkbox" {{if .Rule.BlockOnOutdatedBranch}}checked{{end}}>
+12
View File
@@ -23059,6 +23059,10 @@
"type": "boolean",
"x-go-name": "BlockAdminMergeOverride"
},
"block_on_codeowner_reviews": {
"type": "boolean",
"x-go-name": "BlockOnCodeownerReviews"
},
"block_on_official_review_requests": {
"type": "boolean",
"x-go-name": "BlockOnOfficialReviewRequests"
@@ -23938,6 +23942,10 @@
"type": "boolean",
"x-go-name": "BlockAdminMergeOverride"
},
"block_on_codeowner_reviews": {
"type": "boolean",
"x-go-name": "BlockOnCodeownerReviews"
},
"block_on_official_review_requests": {
"type": "boolean",
"x-go-name": "BlockOnOfficialReviewRequests"
@@ -25441,6 +25449,10 @@
"type": "boolean",
"x-go-name": "BlockAdminMergeOverride"
},
"block_on_codeowner_reviews": {
"type": "boolean",
"x-go-name": "BlockOnCodeownerReviews"
},
"block_on_official_review_requests": {
"type": "boolean",
"x-go-name": "BlockOnOfficialReviewRequests"
+12
View File
@@ -2781,6 +2781,10 @@
"type": "boolean",
"x-go-name": "BlockAdminMergeOverride"
},
"block_on_codeowner_reviews": {
"type": "boolean",
"x-go-name": "BlockOnCodeownerReviews"
},
"block_on_official_review_requests": {
"type": "boolean",
"x-go-name": "BlockOnOfficialReviewRequests"
@@ -3677,6 +3681,10 @@
"type": "boolean",
"x-go-name": "BlockAdminMergeOverride"
},
"block_on_codeowner_reviews": {
"type": "boolean",
"x-go-name": "BlockOnCodeownerReviews"
},
"block_on_official_review_requests": {
"type": "boolean",
"x-go-name": "BlockOnOfficialReviewRequests"
@@ -5150,6 +5158,10 @@
"type": "boolean",
"x-go-name": "BlockAdminMergeOverride"
},
"block_on_codeowner_reviews": {
"type": "boolean",
"x-go-name": "BlockOnCodeownerReviews"
},
"block_on_official_review_requests": {
"type": "boolean",
"x-go-name": "BlockOnOfficialReviewRequests"