From df1a0fff33b920ed2827cc376eb781a737ff7685 Mon Sep 17 00:00:00 2001 From: Robin Jarry Date: Tue, 18 Oct 2022 23:59:34 +0200 Subject: [PATCH] contrib: add git-stats.sh MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git shortlog -sn is nice but it does not display the number of changed files and the amount of changed lines. $ git shortlog -sn 0.12.0.. 46 Tim Culverhouse 28 Robin Jarry 14 Koni Marti 9 Moritz Poldrack 2 Ben Cohen 2 Bence Ferdinandy 2 Julian Pidancet 2 inwit 1 Jason Cox 1 Jason Stewart 1 John Gebbie 1 Tobias Wölfel 1 kt programs Add a simple bash script that adds extra information: $ ./contrib/git-stats.sh 0.12.0.. Author Commits Changed Files Insertions Deletions Tim Culverhouse 46 134 +973 -1090 Robin Jarry 28 70 +671 -358 Koni Marti 14 47 +437 -205 Moritz Poldrack 9 18 +178 -44 Ben Cohen 2 2 +16 -2 Bence Ferdinandy 2 6 +104 +0 Julian Pidancet 2 9 +149 -2 inwit 2 3 +11 -1 Jason Cox 1 7 +106 -6 Jason Stewart 1 1 +4 -2 John Gebbie 1 3 +118 -1 Tobias Wölfel 1 3 +3 -3 kt programs 1 3 +37 -6 Use the script to generate the release tag and email. Signed-off-by: Robin Jarry Acked-on-irc-by: Tim Culverhouse --- contrib/git-stats.sh | 23 +++++++++++++++++++++++ contrib/release.sh | 4 ++-- 2 files changed, 25 insertions(+), 2 deletions(-) create mode 100755 contrib/git-stats.sh diff --git a/contrib/git-stats.sh b/contrib/git-stats.sh new file mode 100755 index 0000000..735817a --- /dev/null +++ b/contrib/git-stats.sh @@ -0,0 +1,23 @@ +#!/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#*,}" diff --git a/contrib/release.sh b/contrib/release.sh index 65f5d7b..464eaad 100755 --- a/contrib/release.sh +++ b/contrib/release.sh @@ -24,8 +24,8 @@ git -c core.commentchar='%' tag --edit --sign \ -m "Release $next_tag highlights:" \ -m "$changes" \ -m "Thanks to all contributors!" \ - -m "~\$ git shortlog -sn $prev_tag..$next_tag -$(git shortlog -sn $prev_tag..)" \ + -m "~\$ contrib/git-stats.sh $prev_tag..$next_tag +$(contrib/git-stats.sh $prev_tag..)" \ "$next_tag" echo "======= Pushing to remote..."