Created
May 19, 2011 21:30
-
-
Save danbeam/981794 to your computer and use it in GitHub Desktop.
svn-author.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# find the most popular author with svn blame | |
svnauthor() { | |
local FILE; | |
local AUTH; | |
local PERCENT; | |
local BIGGEST; | |
local WRITTEN; | |
local TOTAL; | |
for FILE in $*; do | |
SVN_ST=$(svn st $FILE 2>&1); | |
echo $SVN_ST | grep "^A" >/dev/null 2>&1; | |
if [ "$?" -eq "0" ]; then echo "$FILE not committed yet, skipping..."; continue; fi | |
echo $SVN_ST | grep "not a working copy" >/dev/null 2>&1; | |
if [ "$?" -eq "0" ]; then echo "$FILE not under version control, skipping..." && continue; fi | |
BIGGEST=$(svn blame $FILE | awk '{print $2}' | sort | uniq -c | sort -n | tail -1); | |
AUTH=$(echo $BIGGEST | awk '{print $2}'); | |
WRITTEN=$(($(echo $BIGGEST | awk '{print $1}')-1)); | |
TOTAL=$(wc $FILE -l | awk '{print $1}'); | |
PERCENT=$((100*$WRITTEN/$TOTAL)); | |
echo "$FILE: $AUTH ($PERCENT%)"; | |
done; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment