Automatically finding code reviewer candidates

Authored by

Let’s say you’ve made a change to functions.php and config.php in some theme. Who do you assign to code review the changes? One handy way is to use git shortlog -sn. Here’s how to get the top 5 candidates for reviewing a change:

$ git shortlog -sn functions.php config.php | head -n5
    15  Piotr Delawski
    11  Mike Crantea
     8  Ryan Kienstra
     3  Pawel Hajduk

You can replace the highlighted part with whatever files you changed for whatever repo you are on. Or, for something more fancy, if you are on a feature branch and you want to get a list of all the files changed, you can do this:

git shortlog -sn $( git diff --name-only origin/master... ) | head -n5

Naturally you would exclude yourself for code review consideration when you appear in this list 🙂

Please also factor in how busy a given candidate is when you decide whom to assign a ticket for code review.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.