Last active
January 27, 2017 09:58
-
-
Save jow-/537f21a97d432e9d671c45aba0c8da7c to your computer and use it in GitHub Desktop.
Rewrite the commit author to reflect whats in Signed-off-by
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/bash | |
git filter-branch -f --tag-name-filter cat --commit-filter ' | |
eval $(git show --format=%B "$GIT_COMMIT" | sed -ne "s|Signed-off-by: \(.*\) <\(.*\)>$|SOB_AUTHOR='"'"'\\1'"'"'; SOB_EMAIL='"'"'\\2'"'"'|p" | head -n1) | |
if [ -n "$SOB_AUTHOR" -a -n "$SOB_EMAIL" -a "$GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>" != "$SOB_AUTHOR <$SOB_EMAIL>" ]; then | |
echo -e "\nRewrite $GIT_COMMIT: $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> => $SOB_AUTHOR <$SOB_EMAIL>" >&2 | |
export GIT_AUTHOR_NAME="$SOB_AUTHOR" | |
export GIT_AUTHOR_EMAIL="$SOB_EMAIL" | |
fi | |
git commit-tree "$@" | |
' -- "${1:-HEAD~1..HEAD}" | |
git for-each-ref --format="%(refname)" refs/original/ | xargs -r -n 1 git update-ref -d |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment