github-merge-pr: fix loading .config if symbolic link is used
[maintainer-tools.git] / count-contributions.sh
1 #!/usr/bin/env bash
2
3 commit_threshold=100
4 commit_timeframe="$(date --date="5 years ago" +%Y-%m-%d)"
5
6 NL="
7 "
8
9 IFS="$NL"
10 ACTIVE_PEOPLE=""
11
12
13 printf "### Recently active contributors:\n"
14 printf "[Active period begin-end] Commits (Alltime) Name <Mail>\n"
15
16 for line in $(git log --since $commit_timeframe --format="|%aN <%aE>" | sort | uniq -c | sort -nr); do
17 count="${line%% |*}"; count="${count##* }"
18 name="${line#* |}"
19
20 if [ $count -lt $commit_threshold ]; then
21 continue
22 fi
23
24 ACTIVE_PEOPLE="$ACTIVE_PEOPLE$name$NL"
25
26 alltime="$(git log --use-mailmap --author="$name" --format="%aN" | wc -l)"
27 begin="$(git log --use-mailmap --author="$name" --format="%cd" --date="format:%Y-%m-%d" --reverse | head -n1)"
28 end="$(git log --use-mailmap --author="$name" --format="%cd" --date="format:%Y-%m-%d" -1)"
29
30 printf "[%s - %s] %5d (%5d) %s\n" $begin $end $count $alltime "$name"
31 done
32
33 printf "\n"
34 printf "### Important all-time contributors:\n"
35 printf "[Active period begin-end] Commits Name <Mail>\n"
36
37 for line in $(git log --format="|%aN <%aE>" | sort | uniq -c | sort -nr); do
38 count="${line%% |*}"; count="${count##* }"
39 name="${line#* |}"
40
41 if [ $count -lt $commit_threshold ] || echo "$ACTIVE_PEOPLE" | grep -qxF "$name"; then
42 continue
43 fi
44
45 begin="$(git log --use-mailmap --author="$name" --format="%cd" --date="format:%Y-%m-%d" --reverse | head -n1)"
46 end="$(git log --use-mailmap --author="$name" --format="%cd" --date="format:%Y-%m-%d" -1)"
47
48 printf "[%s - %s] %5d %s\n" $begin $end $count "$name"
49 done