Created
February 18, 2014 20:52
-
-
Save tournasdim/9079811 to your computer and use it in GitHub Desktop.
simply execute the script to have a summary of Git statistics per author . Just copy the script into "/usr/bin/" directory and make it executable "chmod +x"
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 | |
LOGOPTS= | |
END_AND_BEGIN= | |
#https://github.com/esc/git-stats | |
#argument parsing | |
while [ -n "$1" ]; do | |
case "$1" in | |
"-s") | |
shift | |
END_AND_BEGIN="$END_AND_BEGIN --after=$1" | |
;; | |
"-e") | |
shift | |
END_AND_BEGIN="$END_AND_BEGIN --before=$1" | |
;; | |
"-w") | |
LOGOPTS="$LOGOPTS -w" | |
;; | |
"-C") | |
LOGOPTS="$LOGOPTS -C --find-copies-harder" | |
;; | |
"-M") | |
LOGOPTS="$LOGOPTS -M" | |
;; | |
esac | |
shift | |
done | |
#test if the directory is a git | |
git branch &> /dev/null || exit 3 | |
echo "Number of commits per author:" | |
git --no-pager shortlog $END_AND_BEGIN -sn --all | |
AUTHORS=$(git shortlog $END_AND_BEGIN -sn --all | cut -f2 | cut -f1 -d' ') | |
for a in $AUTHORS | |
do | |
echo '-------------------' | |
echo "Statistics for: $a" | |
echo -n "Number of files changed: " | |
git log $LOGOPTS $END_AND_BEGIN --all --numstat --format="%n" --author=$a | grep -v -e "^$" | cut -f3 | sort -iu | wc -l | |
echo -n "Number of lines added: " | |
git log $LOGOPTS $END_AND_BEGIN --all --numstat --format="%n" --author=$a | cut -f1 | awk '{s+=$1} END {print s}' | |
echo -n "Number of lines deleted: " | |
git log $LOGOPTS $END_AND_BEGIN --all --numstat --format="%n" --author=$a | cut -f2 | awk '{s+=$1} END {print s}' | |
echo -n "Number of merges: " | |
git log $LOGOPTS $END_AND_BEGIN --all --merges --author=$a | grep -c '^commit' | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment