dotfiles/scripts/git-stats

33 lines
1.0 KiB
Plaintext
Raw Normal View History

2022-02-06 19:45:28 +01:00
#!/bin/bash
TOTALS=`git log --shortstat --author=$author | grep -E "fil(e|es) changed" | awk '{files+=$1; inserted+=$4; deleted+=$6} END {print files, " ", inserted, " ", deleted }'`
TOTAL_INSERTS=`echo $TOTALS | cut -d' ' -f2`
TOTAL_DELETES=`echo $TOTALS | cut -d' ' -f3`
TOTAL_TOTAL=$(( $TOTAL_INSERTS + $TOTAL_DELETES ))
IFS="
"
for author in `git log --format='%aN' | sort -u`; do
echo $author":"
USER=`git log --shortstat --author=$author | grep -E "fil(e|es) changed" | awk '{files+=$1; inserted+=$4; deleted+=$6} END {print files, " ", inserted, " ", deleted }'`
IFS=" "
USER_INSERTS=`echo $USER | cut -d' ' -f2`
USER_DELETES=`echo $USER | cut -d' ' -f3`
USER_TOTAL=`bc <<< "$USER_INSERTS + $USER_DELETES"`
PERC_INSERTS=`bc <<< $USER_INSERTS"* 100 /"$TOTAL_INSERTS`
PERC_DELETES=`bc <<< $USER_DELETES"* 100 /"$TOTAL_DELETES`
PERC_TOTAL=`bc <<< $USER_TOTAL"* 100 /"$TOTAL_TOTAL`
echo " TOTAL: $USER_TOTAL ($PERC_TOTAL%)"
echo " INSERTS: $USER_INSERTS ($PERC_INSERTS%)"
echo " DELETES: $USER_DELETES ($PERC_DELETES%)"
IFS="
"
done