Skip to content

Instantly share code, notes, and snippets.

@edsu
Created December 7, 2012 15:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save edsu/4234093 to your computer and use it in GitHub Desktop.
Save edsu/4234093 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 = {
"ehs@pobox.com": ("Edward Summers", "edsu@loc.gov"),
"eikeon@eikeon.com": ("Daniel Krech", "dkre@loc.gov"),
"acro@darmstadtium.rdc.internal": ("Aaron Croyle", "acro@loc.gov"),
"acro@iodine.rdc.internal": ("Aaron Croyle", "acro@loc.gov"),
"chris@improbable.org": ("Chris Adams", "cadams@loc.gov"),
"dbrun@meitnerium.rdc.internal": ("David Brunton", "dbrun@loc.gov"),
"devnull@localhost": ("Risa Ohara", "rioh@loc.gov"),
"ehs@pobox.com": ("Ed Summers", "edsu@loc.gov"),
"jackiekazil@gmail.com": ("Jackie Kazil", "jkazil@loc.gov"),
"rioh@loc.gov": ("Risa Ohara", "rioh@loc.gov")
}
print \
"""
git filter-branch --env-filter '
"""
for old_email, new_info in emails.items():
print \
"""
if [ $GIT_COMMITTER_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