Monday, April 6, 2015

Finding Git Hotspots or Author Code Experience with a One-liner

On StackOverflow, sometime ago I shared the following command that can help identify the files in a git repo that a certain author has worked with more than others, as part of an attempt what that author had experience working in:

git log --name-only --author="David Heinemeier Hansson" --pretty=format: | sort | uniq -c | sort -nr

And, today, I saw that bugspots was a trending Ruby gem in GitHub, which was based on info from Bug Prediction at Google which in turn was based on work by Foyzur Rahman, Daryl Posnett, Abram Hindle, Earl Barr, and Premkumar Devanbu of UC Davis. I looked and what bugspots currently does is to find messages containing the regexp "/\b(fix(es|ed)?|close(s|d)?)\b/i" to determine what are "hotspots" in the code that were changed more often when fixing bugs.

I quickly modified my one-liner and now have something that can find the files that have been checked in most with the commit message containing "fix". This can help identify "hotspots" for bugs/support-related changes:

git log --name-only --grep="fix" --pretty=format: | sort | uniq -c | sort -nr

No comments: