Reputation: 75
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.secondary
on 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
Upvotes: 2
Views: 2394
Reputation: 1324937
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-admin
repo only, to "compile" the configuration and so on.
(post-receive
is 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 a post-receive
hook in your </path/to/gitolite>/hooks/common/
, as described in "How to install hooks in gitolite".
The OP specialsauce concludes in the comments:
I needed a
post-receive
hook in the repository folder (Rather than a secondary one) , which I think was the main reason that it wasn't executing.The only other thing I changed in the end I believe was setting the perms from
700
(which should have been fine anyway?) to755
.
The hook now executes reliably.I did not need to run the
gl-setup
script. Additionally I changed from the var assignment code as outlined above to a "while" onSTDIN
.
Upvotes: 1