aerc/contrib/git-stats.sh
Robin Jarry a1e81d2128 git-stats.sh: strip trailing white space
Signed-off-by: Robin Jarry <robin@jarry.cc>
2022-10-20 22:20:42 +02:00

24 lines
521 B
Bash
Executable file

#!/bin/bash
set -e
set -o pipefail
columns="Author,Commits,Changed Files,Insertions,Deletions"
git shortlog -sn "$@" |
while read -r commits author; do
git log --author="$author" --pretty=tformat: --numstat "$@" | {
adds=0
subs=0
files=0
while read -r a s f; do
adds=$((adds + a))
subs=$((subs + s))
files=$((files + 1))
done
printf '%s;%d;%d;%+d;%+d;\n' \
"$author" "$commits" "$files" "$adds" "-$subs"
}
done |
column -t -s ';' -N "$columns" -R "${columns#*,}" |
sed -r 's/[[:space:]]+$//'