Created
December 13, 2009 12:41
-
-
Save youpy/255400 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env ruby | |
# usage: git-commit-as github-username -m 'commit message' | |
require 'open-uri' | |
require 'rexml/document' | |
def main | |
username = ARGV.shift | |
userid = userid(username) | |
system('git', 'commit', *ARGV) | |
system(<<COMMAND) | |
git filter-branch -f --commit-filter ' | |
GIT_AUTHOR_NAME="#{username}" | |
GIT_AUTHOR_EMAIL="#{userid}" | |
GIT_COMMITTER_NAME="#{username}" | |
GIT_COMMITTER_EMAIL="#{userid}" | |
git commit-tree "$@" | |
' HEAD^..HEAD | |
COMMAND | |
end | |
def userid(username) | |
doc = REXML::Document.new(open('http://github.com/api/v2/xml/user/show/' + username).read) | |
doc.elements['/user/id'].get_text | |
end | |
main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment