summaryrefslogtreecommitdiff
path: root/maint/thanks.sh
blob: 6c497c87505e34e691c9c004e48d0a86fcd59327 (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
#!/bin/bash
set -euo pipefail

if [ -z "${1-}" ]; then
	echo "Usage: $0 [revision]"
	echo "Script will print thanks for all contributors since [revision]."
	exit 1
fi

TEMPDIR=$(mktemp -d)
TO_EXCLUDE="$(dirname "$0")/exclude_contributors.txt"
LAST_REV=$1

trap 'rm -rf "$TEMPDIR"' 0

echo "[*] Finding contributors since $LAST_REV..."
git log --pretty="%an%n%cn" HEAD "^$LAST_REV" | sort | uniq > "$TEMPDIR/contributors.txt"
echo "[*] Found $(wc -l < "$TEMPDIR/contributors.txt") contributors!"

echo "[*] Removing contributors listed in $TO_EXCLUDE..."
comm -13 "$TO_EXCLUDE" "$TEMPDIR/contributors.txt" | sed 's/^[[:space:]]*\|[[:space:]]*$//g' > "$TEMPDIR/final.txt"
echo "[*] Ended up with $(wc -l < "$TEMPDIR/final.txt") contributors remaining."

readarray -t CONTRIBUTORS < "$TEMPDIR/final.txt"

# from https://stackoverflow.com/a/17841619/4739163
function join_by { local d=${1-} f=${2-}; if shift 2; then printf %s "$f" "${@/#/$d}"; fi; }
OUTPUT=$(join_by ", " "${CONTRIBUTORS[@]}")

echo "Contributors: $OUTPUT"