diff --git a/.mailmap b/.mailmap index 1065aa1f..0baed6f3 100644 --- a/.mailmap +++ b/.mailmap @@ -1 +1,4 @@ <83281+davidsneighbour@users.noreply.github.com> + + + diff --git a/scripts/mailmap b/scripts/mailmap new file mode 100755 index 00000000..d611b6d0 --- /dev/null +++ b/scripts/mailmap @@ -0,0 +1,35 @@ +#!/bin/bash + +paster() { + # shellcheck disable=SC2162 + while read email; do + [ -z "$email" ] || echo "$1" "$email" + done +} + +grouper() { + IFS="<" + # shellcheck disable=SC2162 + read x cur_name email + canonical_email="<"${email} + cur_emails="" + + # shellcheck disable=SC2034,SC2162 + while read x name email; do + if [ "$name" = "$cur_name" ]; then + cur_emails="$cur_emails <${email}" + else + echo "$cur_emails" | tr ' ' '\n' | paster "$canonical_email" + cur_name="$name" + canonical_email="<"${email} + cur_emails="" + fi + done + echo "$cur_emails" | tr ' ' '\n' | paster "$canonical_email" +} + +root_dir="$(git rev-parse --show-cdup)" +root_dir="${root_dir:-.}" +cd "$root_dir" || exit +git shortlog -s -e | tr '\t' '<' | sort -t '<' -k 2,2 -k 1,1nr | grouper | tee "${1:--a}" .mailmap +git add .mailmap