Skip to content

Instantly share code, notes, and snippets.

@mystdeim
Last active December 25, 2020 07:30
Show Gist options
  • Save mystdeim/00484296f0c5774cf85e7ccc89dc9585 to your computer and use it in GitHub Desktop.
Save mystdeim/00484296f0c5774cf85e7ccc89dc9585 to your computer and use it in GitHub Desktop.
Count summary statistics among git repositories in the child directories. Just run it with `./gitstat.sh yourname@example.com`
DIRECTORY=.
WORKING_DIR=$PWD
TMP="$WORKING_DIR/commits"
echo "" > commits
i=0
NAME=$1
echo "Counting stats for $NAME"
for d in $DIRECTORY/*; do
if [ -d "$WORKING_DIR/$d/.git" ]
then
cd $WORKING_DIR/$d
echo $d
VAR=`git log --shortstat --author="$NAME" | grep -E "fil(e|es) changed"`
echo "$VAR" >> $TMP
i=$((i+1))
fi
done
echo "Projects: $i"
cat $TMP | awk '{files+=$1; inserted+=$4; deleted+=$6; delta+=$4-$6} END {printf "Commit stats:\n- Files changed (total).. %s\n- Lines added (total).... %s\n- Lines deleted (total).. %s\n- Total lines (delta).... %s\n- Add./Del. ratio (1:n).. 1 : %s\n", files, inserted, deleted, delta, deleted/inserted }' -
rm $TMP
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment