summaryrefslogtreecommitdiffstats
path: root/count-contributions.sh
blob: 47bf2e0766096f9dbac59288b0c7109068877acd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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