Created
October 20, 2017 07:29
-
-
Save 0x63lv/1a6b9168c8fca19681612d2f89e936f5 to your computer and use it in GitHub Desktop.
Rewrite git commiter information based on mapping
This file contains 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/env bash | |
# This script and mailmapping file should be on the same level as the directory | |
# containing the repo | |
# | |
# mailmapping file should have the following format: | |
# name surname [email protected] [email protected] | |
# | |
# List of commiter names emails can be obtained with: | |
# git shortlog -sne | |
# this information can be used to craft the mailmapping file | |
repo_name="repo-dir-name-goes-here" | |
input_file="../mailmapping" | |
cd "$repo_name" | |
while read name surname email old_email | |
do | |
export OLD_EMAIL=$old_email | |
export CORRECT_EMAIL=$email | |
export CORRECT_NAME=$name | |
export CORRECT_SURNAME=$surname | |
git filter-branch -f --env-filter ' | |
if test "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" | |
then | |
export GIT_COMMITTER_NAME="$CORRECT_NAME $CORRECT_SURNAME" | |
export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL" | |
fi | |
if test "$GIT_AUTHOR_EMAIL" = "$OLD_EMAIL" | |
then | |
export GIT_AUTHOR_NAME="$CORRECT_NAME $CORRECT_SURNAME" | |
export GIT_AUTHOR_EMAIL="$CORRECT_EMAIL" | |
fi | |
' --tag-name-filter cat -- --all | |
done < "$input_file" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment