Skip to content

Instantly share code, notes, and snippets.

@takac
Last active December 20, 2015 05:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save takac/6079347 to your computer and use it in GitHub Desktop.
Save takac/6079347 to your computer and use it in GitHub Desktop.
Git Contributor Rank
# Contributor Ranking
#
# Author: Tom Cammann
#
function contrib_list {
# Find all email address names used to commit
authors=$( git log --format='%aE' | cut -d"@" -f1 | sort -u )
# For each commit match no binary files that have changed and capture the number
# Only match java files
for i in ${authors}; do
echo "$i" $(git log --author="$i" --no-merges --stat | awk 'BEGIN{ FS="|"} /.*\.java/{match($2, /^ *([0-9]+)/,a); x += a[1] } END { print x }')
done
}
# Create a mapping from username to commit lines
# Add differnt cases of names together.
n=1
for i in $(contrib_list | awk '
BEGIN{ FS=" " }
{a[tolower($1)] += $2 }
END{
for( name in a )
print name "=" a[name]
}' | sort -t"=" -k2 -rn); do
x=$( echo $i | tr "=" " ")
echo "${n}. $x"
(( n++ ))
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment