2023-01-25 17:35:53 +00:00
|
|
|
#!/usr/bin/env bash
|
2021-10-29 15:28:26 +01:00
|
|
|
set -euo pipefail
|
|
|
|
|
|
|
|
if [ -z "${1-}" ]; then
|
|
|
|
echo "Usage: $0 [revision]"
|
|
|
|
echo "Script will print thanks for all contributors since [revision]."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2023-05-18 18:20:32 +01:00
|
|
|
# from https://stackoverflow.com/a/17841619/4739163
|
|
|
|
function join_by { local d=${1-} f=${2-}; if shift 2; then printf %s "$f" "${@/#/$d}"; fi; }
|
|
|
|
|
2021-10-29 15:28:26 +01:00
|
|
|
TEMPDIR=$(mktemp -d)
|
2021-10-29 15:35:37 +01:00
|
|
|
TO_EXCLUDE="$(dirname "$0")/exclude_contributors.txt"
|
2021-10-29 15:28:26 +01:00
|
|
|
LAST_REV=$1
|
|
|
|
|
2023-05-18 18:20:32 +01:00
|
|
|
WE_CREDIT=(
|
|
|
|
# Name of the author.
|
|
|
|
%an
|
|
|
|
# Name of the committer.
|
|
|
|
%cn
|
|
|
|
# Anybody in Reported-by. (These are case-insensitive, don't worry.)
|
|
|
|
"%(trailers:valueonly=true,key=Reported-by)"
|
|
|
|
# Anybody in Co-Authored-By.
|
|
|
|
"%(trailers:valueonly=true,key=Co-Authored-by)"
|
|
|
|
# Anybody in Thanks.
|
|
|
|
"%(trailers:valueonly=true,key=Thanks)"
|
|
|
|
)
|
|
|
|
PRETTY=$(join_by "%n" "${WE_CREDIT[@]}")
|
|
|
|
|
2021-10-29 15:37:33 +01:00
|
|
|
trap 'rm -rf "$TEMPDIR"' 0
|
|
|
|
|
2021-10-29 15:28:26 +01:00
|
|
|
echo "[*] Finding contributors since $LAST_REV..."
|
2023-05-18 18:27:03 +01:00
|
|
|
git log --pretty="$PRETTY" HEAD "^$LAST_REV" | grep . | sed 's/ *<[^>]*>$//' | sort | uniq > "$TEMPDIR/contributors.txt"
|
2021-10-29 15:35:37 +01:00
|
|
|
echo "[*] Found $(wc -l < "$TEMPDIR/contributors.txt") contributors!"
|
2021-10-29 15:28:26 +01:00
|
|
|
|
|
|
|
echo "[*] Removing contributors listed in $TO_EXCLUDE..."
|
|
|
|
comm -13 "$TO_EXCLUDE" "$TEMPDIR/contributors.txt" | sed 's/^[[:space:]]*\|[[:space:]]*$//g' > "$TEMPDIR/final.txt"
|
2021-10-29 15:35:37 +01:00
|
|
|
echo "[*] Ended up with $(wc -l < "$TEMPDIR/final.txt") contributors remaining."
|
2021-10-29 15:28:26 +01:00
|
|
|
|
|
|
|
readarray -t CONTRIBUTORS < "$TEMPDIR/final.txt"
|
|
|
|
|
|
|
|
OUTPUT=$(join_by ", " "${CONTRIBUTORS[@]}")
|
|
|
|
|
|
|
|
echo "Contributors: $OUTPUT"
|
|
|
|
|