Hello,
Can I see somewhere an example post-commit hook to run a script on each commited file?
eg.
git add file1
git add file2
git commit -am "my commit"
and the hook executes:
myscript -myparams "file1"
myscript -myparams "file2"
The best would be to have parameter to commit command to run this hook or not, eg. git commit -X
… executes this post commit hook. Eventually an alias like git-commitx
.
How about the same version as a pre-commit hook on files in index? Can I abort a commit when execution of the scripts fails on one of the files?
Edit:
Here is what I have now:
#!/bin/sh
#.git/hooks/post-commit
dir=`pwd`
echo ----------------------------------------------
echo PHP Mess Detector results for commited files:
echo ----------------------------------------------
git show --pretty="format:" --name-only | grep '\.php$' | xargs -i phpmd $dir/'{}' text codesize,unused$
echo ----------------------------------------------