Skip to content

Instantly share code, notes, and snippets.

@acdha
Forked from edsu/rewrite.py
Created December 14, 2012 16:44
Show Gist options
  • Save acdha/4286803 to your computer and use it in GitHub Desktop.
Save acdha/4286803 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
"""
A silly script to write a git filter-branch command to rewrite
various email addresses to be ALL OFFICIAL AND STUFF.
usage
=====
./rewrite.py > rewrite.sh
chmod a+x rewrite.sh
./rewrite.sh
"""
import os
import sys
e = os.environ
emails = {
"[email protected]": ("Edward Summers", "[email protected]"),
"[email protected]": ("Daniel Krech", "[email protected]"),
"[email protected]": ("Aaron Croyle", "[email protected]"),
"[email protected]": ("Aaron Croyle", "[email protected]"),
"[email protected]": ("Chris Adams", "[email protected]"),
"[email protected]": ("David Brunton", "[email protected]"),
"devnull@localhost": ("Risa Ohara", "[email protected]"),
"[email protected]": ("Ed Summers", "[email protected]"),
"[email protected]": ("Jackie Kazil", "[email protected]"),
"[email protected]": ("Risa Ohara", "[email protected]")
}
print \
"""
#!/usr/bin/bash
git filter-branch --env-filter '
"""
for old_email, new_info in emails.items():
print \
"""
if [[ $GIT_COMMITTER_EMAIL = "%(old_email)s" || $GIT_AUTHOR_EMAIL = "%(old_email)s" ]]; then
GIT_COMMITTER_EMAIL="%(email)s";
GIT_AUTHOR_EMAIL="%(email)s";
GIT_AUTHOR_NAME="%(name)s";
GIT_COMMITTER_NAME="%(name)s";
fi
""" % {"old_email": old_email, "email": new_info[1], "name": new_info[0]}
print \
"""
' -- --all
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment