where to start with CODEOWNERS when nobody owns anything yet #213307
🏷️ Discussion TypeQuestion Bodyif CODEOWNERS feels like too big a project, starting with the files that change most has worked well. rank files by commits over the last year with git log, then count how many different people touched each one. the files near the top with lots of authors and no one owning most of the changes are where reviews are weakest, every change gets approved by someone holding half the picture. an owner on just those ten or twenty files, plus "require review from code owners" in the ruleset, puts the person with context on most of the risky PRs. everything else keeps the normal flow. we track this as Code Volatility in the reliability score we build at Tomosu, because the same change reads very differently in a hot ownerless file than in a quiet one. the git commands with real output from the Celery repo are here https://tomosu.ai/blogs/code-churn-hotspots.html?utm_source=github&utm_medium=discussion&utm_campaign=codeowners-hotspots curious how others picked which files got owners first, by churn, by incident history, or something else? |
Replies: 2 comments 2 replies
|
I’d use churn as the first filter, then prioritize paths with a bigger impact when something breaks, such as auth, migrations, and deployment workflows. That keeps high-churn lockfiles or generated files from crowding out code that’s harder to review safely. Before enabling required reviews, make sure each chosen path has a backup owner. GitHub lets you list multiple owners on the same pattern, and approval from any one of them satisfies the code-owner requirement. Then try a small PR that touches each pattern to check who gets requested. Put broad patterns before narrower ones, because the last matching pattern wins. |
|
Churn as the first filter is sensible, but I'd add one derived signal: author diversity on the same path. A file with 40 commits from one person is well owned even if nobody is in CODEOWNERS. A file with 12 commits from six people and no clear owner is where reviews are weakest — that's the one to fix first. You can get both numbers locally without any tooling beyond Git: # churn: most-changed paths in the last year
git log --since='1 year ago' --name-only --pretty=format: \
| sed '/^$/d' | sort | uniq -c | sort -rn | head -40
# for a candidate path: how many different authors touched it
git log --since='1 year ago' --format='%ae' -- path/to/file | sort -u | wc -l
# account for renames
git log --follow --since='1 year ago' --name-only --pretty=format: -- path/to/fileThen rank by something like
What survives is usually a short list: auth, migrations, the deployment workflow, the API router, the billing/critical-path module. That's your first CODEOWNERS file. A few things that matter when you actually roll it outUse teams, not people. The owner should be a team (e.g. Require one approval, not all. In the ruleset, enable "Require review from Code Owners" with a single approval from any matching owner. Requiring every listed owner turns the hot files into a queue. Start narrow and expand. Put owners on 10–20 paths, leave everything else unowned, and enable the rule. Then check after a month: which PRs still got reviewed by someone without context? Add those paths. This is much easier to get accepted by a team than a big-bang CODEOWNERS file covering the whole repo. Cross-reference incidents. Churn tells you where change is frequent; incident history tells you where mistakes are expensive. If you have an incident log or a Don't forget CI config. To answer your actual question — churn, incident history, or something else — I'd use churn to generate candidates, incident history to prioritise them, and author diversity to confirm that ownership is genuinely missing. Each signal alone overweights one kind of risk. More development workflow notes on my GitHub if you'd like: https://github.com/P-r-e-m-i-u-m |
Churn as the first filter is sensible, but I'd add one derived signal: author diversity on the same path. A file with 40 commits from one person is well owned even if nobody is in CODEOWNERS. A file with 12 commits from six people and no clear owner is where reviews are weakest — that's the one to fix first.
You can get both numbers locally without any tooling beyond Git: