1
0
Fork 0
mirror of https://git.sr.ht/~rjarry/aerc synced 2025-02-22 14:53:57 +01:00
aerc/contrib/git-stats.sh
Maarten Aertsen 65571b67d7 contrib: use sed -E for shell scripts
The + character is not part of the 'basic regular expressions' in BSD
grep. Use -E to enable extended (modern) regular expressions. Also
remove escaping. This makes the commit msg hook work on macOS 14.2.

Signed-off-by: Maarten Aertsen <maarten@nlnetlabs.nl>
Signed-off-by: Robin Jarry <robin@jarry.cc>
2024-02-29 00:04:21 +01:00

38 lines
833 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 -E 's/[[:space:]]+$//'
echo
columns="Reviewer/Tester,Commits"
git shortlog -sn \
--group=trailer:acked-by \
--group=trailer:tested-by \
--group=trailer:reviewed-by "$@" |
while read -r commits author; do
printf '%s;%s\n' "$author" "$commits"
done |
column -t -s ';' -N "$columns" -R "${columns#*,}" |
sed -E 's/[[:space:]]+$//'