Finding the right people to review your patch can be tough. I see the question "who should I add as reviewer for this patch?" popping up on IRC quite regularly and not something I'm unfamiliar with myself.
Not every project has a list of code owners and as soon as your change spans multiple components things might get tricky. Preferable you want reviewers that know the code you've changed. If the project is using
git you can use
git blame to find out for each individual line of a file, who changed it last.
If we use this information and count the people that have the most changes in the files we modified, we can get a pretty accurate idea of good candidates for reviewing a change. The command below does exactly that, using nothing more than the tools that are available by default. While it's pretty slow due to the large output of
git blame, it gets the job done in a portable way.
git diff --name-only --cached | xargs -n 1 git blame --porcelain | grep \"^author \" | sort | uniq -c | sort -nr | head -10
If you like using
git's aliases (I do!) you can add the command to your
~/.gitconfig by prefixing it with an exclamation mark as shown below, and invoking it as
[alias] reviewers = !git diff --name-only --cached | xargs -n 1 git blame --porcelain | grep \"^author \" | sort | uniq -c | sort -nr | head -10