Created
February 25, 2020 07:36
-
-
Save arzzen/584d75b0da8190d747e9db8b9d47522d to your computer and use it in GitHub Desktop.
mailmap.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh | |
paster() { | |
while read email; do | |
[ -z "$email" ] || echo "$1" "$email" | |
done | |
} | |
grouper() { | |
IFS="<" | |
read x cur_name email | |
canonical_email="<"${email} | |
cur_emails="" | |
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" | |
git shortlog -s -e|tr '\t' '<'|sort -t '<' -k 2,2 -k 1,1nr|grouper|tee ${1:--a} .mailmap | |
git add .mailmap |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment