Showing results for 
Search instead for 
Did you mean: 
Copilot Lvl 2
Message 1 of 12

CODEOWNER Required Reviews

Solved! Go to Solution.

I've got a repository with 3 total collaborators, and the master/dev branches are set up to be:

  • protected
  • require PR reviews
  • require review from Code Owners


Now, as I understood things, my open PR towards the dev branch should request a review from all Code Owners, but a single approved review should be enough to review.


My PR automatically requested review from the other two collaborators, since both are Code Owners. So far, so good. One of them requested changes, which we discussed, made, and then approved. So the current status of his review is "approved"--yet this is not enough to merge the PR?


The status box says


Code owner review required
Waiting on code owner review from xxxxxxxxxxxx.
Required statuses must pass before merging
All required status checks on this pull request must run successfully to enable automatic merging.
There are no status checks enabled (beyond required reviews), and I have at least one approved review, so I fail to see why the merge button didn't turn that shiny Green (I have full privilege on the repo, so presumably I can merge when the review is approved).
Is there any way to make sure at least one approved review is enough to merge the PR, or is this one of those "since it's your PR you can't merge it" things?
11 Replies
Community Manager
Message 2 of 12

Re: CODEOWNER Required Reviews

It's hard to say why you're experiencing this behavior without some more information. Is the repository in question public? Can you share a link to a specific PR that is behaving in a way that you believe is not expected?


Assuming that the repository in question is private, I can guess at one reason why more than one reviewer might be required. Let's say you have a CODEOWNERS like the following:


*        @foo @bar @baz

In this case, any PR would require one (and only one) of those three people to approve it before it could be merged. But let's say you have a more complex CODEOWNERS file:


*.js        @foo @bar
docs/       @baz

And you submit a PR that includes both a JavaScript change as well as a change to some associated documentation. That PR would require one of either foo or bar to approve it for the JavaScript change and a separate approval from baz for the documentation.


Maybe you could share just your CODEOWNERS file?

Copilot Lvl 2
Message 3 of 12

Re: CODEOWNER Required Reviews

I figured it out; it was similar to what you describe below, where my changes were targeting two different patterns, requiring a review from two separate people to approve each change.


Thanks for your help!

Ground Controller Lvl 1
Message 4 of 12

Re: CODEOWNER Required Reviews

Elsewhere you have said you can specify code owners for specific branches. Can you please give an example?

Community Manager
Message 5 of 12

Re: CODEOWNER Required Reviews

There is an example in the CODEOWNERS help documentation. Let us know if you have any questions about it.

Copilot Lvl 2
Message 6 of 12

Re: CODEOWNER Required Reviews

hey @lee-dohm

I don't see any code example.  I found a blurb about branches, but nothing telling us how

Each CODEOWNERS file assigns the code owners for a single branch in the repository. Thus, you can assign different code owners for different branches, such as @octo-org/codeowners-team for a code base on the master branch and @octocat for a GitHub Pages site on the gh-pages branch.

on the docs page; what does an actual branch reference look like?  would we have a new CODEOWNERS file per branch, or would we have the same CODEOWNERS file with all the branches and reviewers listed?

Community Manager
Message 7 of 12

Re: CODEOWNER Required Reviews

It's probably better explained by saying that the one CODEOWNERS file has different contents per branch. So if there is one rule in the file on the `master` branch but a different rule in the file on the `foo` branch, then the first rule applies when things are being merged into `master` and the second rule applies when things are being merged into `foo`. In both cases, the format of the CODEOWNERS file is the same and there is no mention of a branch reference within the contents of the CODEOWNERS file itself.

Copilot Lvl 2
Message 8 of 12

Re: CODEOWNER Required Reviews

So how do you avoid the PR merge from one branch to another overwrite the CODEOWNERS file with different content?


Copilot Lvl 2
Message 9 of 12

Re: CODEOWNER Required Reviews

*        @foo @bar @baz

"In this case, any PR would require one (and only one) of those three people to approve it before it could be merged"


Is there any way to require all of the listed people to approve?

Community Manager
Message 10 of 12

Re: CODEOWNER Required Reviews

No, there currently isn't a way to do that built-in to the CODEOWNERS feature. If that was the one and only rule, you could do a hacky solution where you required a PR to have three approvals to be merged but if the CODEOWNERS contents ever changed, you would have to remember to manually update the number of required reviews. So it isn't something I would recommend as a solution to the question you're asking.