I'm trying to write a post-commit hook, I have a Git repository on a mapped drive (V:), msysgit installed in C:\Git, and Python in C:\Python26.
I'm running TortoiseGit on Windows 7 64 Bit.
The script is:
#!C:/Python26/python
import sys
from subprocess import Popen, PIPE, call
GIT_PATH = 'C:\Git\bin\git.exe'
BRANCHES = ['master']
TRAC_ENV = 'C:\TRAC_ENV'
REPO_NAME = 'core'
def call_git(command, args):
return Popen([GIT_PATH, command] + args, stdout=PIPE).communicate()[0]
def handle_ref(old, new, ref):
# If something else than the master branch (or whatever is contained by the
# constant BRANCHES) was pushed, skip this ref.
if not ref.startswith('refs/heads/') or ref[11:] not in BRANCHES:
return
# Get the list of hashs for commits in the changeset.
args = (old == '0' * 40) and [new] or [new, '^' + old]
pending_commits = call_git('rev-list', args).splitlines()[::-1]
call(["trac-admin", TRAC_ENV, "changeset", "added", REPO_NAME] + pending_commits)
if __name__ == '__main__':
for line in sys.stdin:
handle_ref(*line.split())
If I run the "git commit..." command from command line, it doesn't seem to even run the hook script at all.