I want to add a commit hook that works when a push is received on a gitolite/git server for a given branch and repo combination only (branch ‘cat’ on repo ‘dog’).
My environment:
git version 1.7.4.1,
What I have done so far:
-
Touched a file at
/home/git/repositories/dog.git/hooks/post-receive.secondaryon the git/gitolite server. -
Edited the file with the contents:
#!/bin/sh # refname="$1" oldrev="$2" newrev="$3" if [ "$refname" == "refs/heads/cat" ] then touch /tmp/test fi -
Set the owner of the file to the ‘git’ user
-
Set the file permissions to 700
-
Done a commit to “cat” branch of “dog” repo
Results:
the test file is not created
If I look at Gitolite v2 (g2) hook chaining section, only two hooks are concerned with the “
.secondary” extension:The post-update hook, because it is used in the
gitolite-adminrepo only, to “compile” the configuration and so on.(
post-receiveis only involved if mirroring is activated, which shouldn’t be the case in your gitolite installation)So you shouldn’t need to declare a
post-receive.secondary, just apost-receivehook in your</path/to/gitolite>/hooks/common/, as described in “How to install hooks in gitolite“.The OP specialsauce concludes in the comments: