Skip to content

Add block on pending codeowner reviews branch protection #34995

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Naxdy
Copy link
Contributor

@Naxdy Naxdy commented Jul 8, 2025

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), as I think it makes sense to do that in a separate PR, as it doesn't require any database migrations.

Screenshot

Pull Request
Branch Protection Rule

Unresolved questions

  • Does this warrant a doc change?

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Jul 8, 2025
@github-actions github-actions bot added modifies/translation modifies/api This PR adds API routes or modifies them modifies/go Pull requests that update Go code modifies/templates This PR modifies the template files modifies/migrations labels Jul 8, 2025
@Naxdy Naxdy force-pushed the work/codeowner-review branch 5 times, most recently from 7ff6bd4 to 7141ade Compare July 8, 2025 13:01
@Naxdy Naxdy marked this pull request as ready for review July 8, 2025 13:02
@Naxdy Naxdy force-pushed the work/codeowner-review branch 2 times, most recently from 39ba543 to 18cce17 Compare July 11, 2025 16:43
@lunny lunny added this to the 1.25.0 milestone Jul 11, 2025
@lunny lunny added the type/enhancement An improvement of existing functionality label Jul 11, 2025
@Naxdy Naxdy requested a review from lunny July 11, 2025 21:00
@Naxdy Naxdy force-pushed the work/codeowner-review branch 3 times, most recently from a5035a7 to 5df3166 Compare July 12, 2025 08:42

hasApprovals := true

for _, rule := range rules {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic appears overly complex and doesn’t seem correct. I ran a test, and it didn’t work as expected. Could you please rewrite it to make it clearer and more readable?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran a test, and it didn’t work as expected.

Can you give me more info about that, like the codeowner file you used and what you expected vs. what happened?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also went and amended it to be a bit more concise. The behavior should be unchanged though, so I'd still be interested in your findings.

@Naxdy Naxdy force-pushed the work/codeowner-review branch 2 times, most recently from 9b575f8 to b448f2c Compare July 15, 2025 08:58
@Naxdy Naxdy force-pushed the work/codeowner-review branch from b448f2c to e01ac3d Compare July 15, 2025 09:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. modifies/api This PR adds API routes or modifies them modifies/go Pull requests that update Go code modifies/migrations modifies/templates This PR modifies the template files modifies/translation type/enhancement An improvement of existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Code Owners feature not enforceable
3 participants