Skip to content

Instantly share code, notes, and snippets.

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 danbeam/981794 to your computer and use it in GitHub Desktop.
Save danbeam/981794 to your computer and use it in GitHub Desktop.
svn-author.sh
# 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