added git_stats function to git plugin collection
parent
0798a8034a
commit
b2857a3774
|
|
@ -54,3 +54,42 @@ function git_info() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function git_stats {
|
||||||
|
# awesome work from https://github.com/esc/git-stats
|
||||||
|
# including some modifications
|
||||||
|
|
||||||
|
if [ -n "$(git symbolic-ref HEAD 2> /dev/null)" ]; then
|
||||||
|
echo "Number of commits per author:"
|
||||||
|
git --no-pager shortlog -sn --all
|
||||||
|
AUTHORS=$( git shortlog -sn --all | cut -f2 | cut -f1 -d' ')
|
||||||
|
LOGOPTS=""
|
||||||
|
if [ "$1" == '-w' ]; then
|
||||||
|
LOGOPTS="$LOGOPTS -w"
|
||||||
|
shift
|
||||||
|
fi
|
||||||
|
if [ "$1" == '-M' ]; then
|
||||||
|
LOGOPTS="$LOGOPTS -M"
|
||||||
|
shift
|
||||||
|
fi
|
||||||
|
if [ "$1" == '-C' ]; then
|
||||||
|
LOGOPTS="$LOGOPTS -C --find-copies-harder"
|
||||||
|
shift
|
||||||
|
fi
|
||||||
|
for a in $AUTHORS
|
||||||
|
do
|
||||||
|
echo '-------------------'
|
||||||
|
echo "Statistics for: $a"
|
||||||
|
echo -n "Number of files changed: "
|
||||||
|
git log $LOGOPTS --all --numstat --format="%n" --author=$a | cut -f3 | sort -iu | wc -l
|
||||||
|
echo -n "Number of lines added: "
|
||||||
|
git log $LOGOPTS --all --numstat --format="%n" --author=$a | cut -f1 | awk '{s+=$1} END {print s}'
|
||||||
|
echo -n "Number of lines deleted: "
|
||||||
|
git log $LOGOPTS --all --numstat --format="%n" --author=$a | cut -f2 | awk '{s+=$1} END {print s}'
|
||||||
|
echo -n "Number of merges: "
|
||||||
|
git log $LOGOPTS --all --merges --author=$a | grep -c '^commit'
|
||||||
|
done
|
||||||
|
else
|
||||||
|
echo "you're currently not in a git repository"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue