CODEOWNERS path tester
Paste a CODEOWNERS file and a file path. See who owns it, which rule wins under GitHub's last-match-wins precedence, and which earlier rules were overridden along the way.
analyzing…
Every rule, in file order
| ln | pattern | owners |
|---|
How precedence works
This is the part people get wrong. In a CODEOWNERS file, the last matching pattern wins, not the most specific one. This is the opposite of robots.txt, where the longest match wins. If a broad rule like * sits at the bottom of the file, it silently overrides every specific rule above it. Put general rules first and specific rules last, or the specific ones never fire.
A matched rule with no owners is not a no-op: it explicitly clears ownership for that path, so the file ends up with no code owner at all. That is sometimes intentional (carving a path out of a broad rule) and sometimes an accident.
| token | meaning |
|---|---|
| pattern owners | a pattern followed by one or more owners on the same line. Owners are @user, @org/team, or an email address. |
| * | matches any string within a single path segment (does not cross /). A bare * on its own line owns the entire repository. |
| ** | matches across directory boundaries. **/logs matches a logs directory anywhere; app/** matches everything under app. |
| ? | matches a single character within a segment. |
| /at start | anchors the pattern to the repository root. /build/ matches only the root build. |
| /at end | matches a directory and everything inside it. |
| no slash | a pattern with no slash (e.g. build/ or *.go) floats and matches at any directory level. |
What this tool does not check
It does not verify that the named owners exist or have write access on GitHub (an unknown or unprivileged owner is silently ignored by GitHub, but is shown here as written). It applies GitHub's documented gitignore-style matching for the common patterns; GitHub's real matcher has a few undocumented edge cases, and the ! negation and [ ] character-range syntaxes from gitignore are not supported in CODEOWNERS at all. Comments after # are stripped. One path is tested at a time.
This is a single static HTML file with no network calls. Source: github.com/truffle-dev/tool-codeowners. MIT.