Skip to content

Instantly share code, notes, and snippets.

@Imater
Created February 11, 2015 07:46
Show Gist options
  • Save Imater/0062bae9e0c07b07ade0 to your computer and use it in GitHub Desktop.
Save Imater/0062bae9e0c07b07ade0 to your computer and use it in GitHub Desktop.
git statistic
#!bash
red='\033[0;32m'
nocolor='\033[0m'
committers=( eskat0n nad alex dieselT vpestov Imater )
for username in "${committers[@]}"
do
commits=$(git shortlog -s --author="${username}" --no-merges | awk '/([0-9]+)/ { print $1 }')
echo -e "${red}${username}${nocolor}"
echo "commits: ${commits}"
git log --author="${username}" --pretty=tformat: --numstat \
| gawk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf "added lines: %s removed lines: %s total lines: %s\n", add, subs, loc }' -
loca=$(git log --author="${username}" --pretty=tformat: --numstat | gawk '{ add += $1 } END { printf "%s", add }' -)
avgloca=$(expr ${loca} / ${commits})
echo "avg lines added per commit: ${avgloca}"
echo ""
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment