Created
April 9, 2010 13:57
-
-
Save JakeWharton/361182 to your computer and use it in GitHub Desktop.
git post-receive hook for updating Trac 0.12
This file contains hidden or 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/python | |
import sys | |
import subprocess | |
GIT_PATH = '/usr/bin/git' | |
TRAC_ADMIN_PATH = '/usr/local/bin/trac-admin' | |
VALID_BRANCHES = ['master'] | |
TRAC_ENV = '/path/to/trac' | |
REPO_NAME = 'somerepo' | |
if __name__ == '__main__': | |
for line in sys.stdin: | |
old, new, ref = line.split() | |
if ref.startswith('refs/heads/') and ref[11:] in VALID_BRANCHES: | |
args = [new] if old == '0' * 40 else [new, '^' + old] | |
pending_commits = subprocess.Popen([GIT_PATH, 'rev-list'] + args, stdout=subprocess.PIPE).communicate()[0].splitlines()[::-1] | |
subprocess.call([TRAC_ADMIN_PATH, TRAC_ENV, "changeset", "added", REPO_NAME] + pending_commits) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment