Created
August 20, 2013 09:02
-
-
Save timofurrer/6279011 to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
if [ -z "$1" ]; then | |
echo Error: please specify a file >&2 | |
exit 1 | |
fi | |
for f in $@; do | |
if [ ! -f "$f" ]; then | |
echo "Error: file '$f' does not exist" >&2 | |
exit 2 | |
fi | |
lines=`cat "$f" | wc -l` | |
echo "Blame stats for $f" | |
echo "Percentage Lines Author" | |
echo ============================================ | |
git blame --line-porcelain "$f" | sed -n 's/^author //p' | sort | uniq -c | sort -rn | awk -v lines=$lines '{ percentage = 100/lines*$1; sub(/^[ \t]+/,"", $0); sub(/[ \t]+$/,"", $0); printf "%5.2f %% %4d l ", percentage, $1; $1 = ""; print $0; }' | |
echo ============================================ | |
echo Lines of file $lines | |
echo | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment