Where is the logic how CODEOWNERS works on auto assigning?

I’d like to ask the situation when PR matches multiple distinguished rules. Said that we have a CODEOWNERS files like:

*.js @foo @bar
docs/ @bar @baz

If someone make a PR touches both JS files and docs folder, is GitHub choose only @bar as the reviewer, or it must require two different reviewers, or some other behavior?

And further, I don’t see a detailed spec describes all these cases how CODEOWNERS file would work. Please DO NOT send me this links, they roughly say little about details. If I want to use it, I’d like to understand most of its behaviors.


Order is important; the last matching pattern takes the most

That’s a bit unclear documented in the comments of the example file:

Since GitHub Docs are now OS, you can create a suggestion for this docs.

1 Like

What if there is nothing about order, I mean, a PR touch


It is my case. Possibly a PR may touch a wide range of file and I’d like to merge CODEOWNERS as many as possible, so that less people be notified (disturbed).

1 Like

I don’t really understand what you mean.
Just read the comments from the mentioned example file.

1 Like

Order is important; the last matching pattern takes the most precedence.

works for one sort of matches, but what if I have two sort of matches.

My understanding is that if multiple owner rules are matched, an owner from each rule is required to review the PR. So if index.js and docs/index.md are both edited, either @bar or both @foo and @baz must review the PR.

Note that each rule is combined with “or,” not “and”

Yep. That sounds correct.

I’ve dropped CODEOWNERS file and think this is the solution. Close with a like solution.

Thanks for your advice @micimize !