count-contributions.sh: add script to count number of commits
authorJo-Philipp Wich <jo@mein.io>
Sun, 4 Nov 2018 15:59:50 +0000 (16:59 +0100)
committerJo-Philipp Wich <jo@mein.io>
Fri, 6 Mar 2020 11:28:41 +0000 (12:28 +0100)
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
count-contributions.sh [new file with mode: 0755]

diff --git a/count-contributions.sh b/count-contributions.sh
new file mode 100755 (executable)
index 0000000..47bf2e0
--- /dev/null
@@ -0,0 +1,49 @@
+#!/usr/bin/env bash
+
+commit_threshold=100
+commit_timeframe="$(date --date="5 years ago" +%Y-%m-%d)"
+
+NL="
+"
+
+IFS="$NL"
+ACTIVE_PEOPLE=""
+
+
+printf "### Recently active contributors:\n"
+printf "[Active period begin-end] Commits (Alltime) Name <Mail>\n"
+
+for line in $(git log --since $commit_timeframe --format="|%aN <%aE>" | sort | uniq -c | sort -nr); do
+       count="${line%% |*}"; count="${count##* }"
+       name="${line#* |}"
+
+       if [ $count -lt $commit_threshold ]; then
+               continue
+       fi
+
+       ACTIVE_PEOPLE="$ACTIVE_PEOPLE$name$NL"
+
+       alltime="$(git log --use-mailmap --author="$name" --format="%aN" | wc -l)"
+       begin="$(git log --use-mailmap --author="$name" --format="%cd" --date="format:%Y-%m-%d" --reverse | head -n1)"
+       end="$(git log --use-mailmap --author="$name" --format="%cd" --date="format:%Y-%m-%d" -1)"
+
+       printf "[%s - %s] %5d (%5d) %s\n" $begin $end $count $alltime "$name"
+done
+
+printf "\n"
+printf "### Important all-time contributors:\n"
+printf "[Active period begin-end] Commits Name <Mail>\n"
+
+for line in $(git log --format="|%aN <%aE>" | sort | uniq -c | sort -nr); do
+       count="${line%% |*}"; count="${count##* }"
+       name="${line#* |}"
+
+       if [ $count -lt $commit_threshold ] || echo "$ACTIVE_PEOPLE" | grep -qxF "$name"; then
+               continue
+       fi
+
+       begin="$(git log --use-mailmap --author="$name" --format="%cd" --date="format:%Y-%m-%d" --reverse | head -n1)"
+       end="$(git log --use-mailmap --author="$name" --format="%cd" --date="format:%Y-%m-%d" -1)"
+
+       printf "[%s - %s] %5d %s\n" $begin $end $count "$name"
+done