J'essaye d'écrire un post-commit hook, j'ai un dépôt Git sur un lecteur mappé (V :), msysgit installé dans C: \ Git, et Python dans C: \ Python26. Je cours TortoiseGit sur Windows 7 64 bits.erreur git: ne peut pas apparaître .git/hooks/post-commit: Aucun fichier ou répertoire
Le script est:
#!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())
Si je lance la commande « git commit ... » de la ligne de commande, il ne semble pas fonctionner même le script de crochet du tout.
Donc ... l'erreur dans le titre de votre question se produit lorsque vous essayez de valider via TortoiseGit, et une validation de ligne de commande fonctionne correctement (juste sans exécuter le crochet), non? Est-ce que le hook est bien dans '.git/hooks/post-commit', et exécutable? – Cascabel