It is quite possible to skip post-receive
hook with use of push-options
.
To make is happen you need three ingredients:
1)
According to man githooks
, post-receive section:
The number of push options given on the command line of git push --push-option=... can be read from the environment variable GIT_PUSH_OPTION_COUNT, and the options themselves are found in GIT_PUSH_OPTION_0, GIT_PUSH_OPTION_1,... If it is negotiated to not use the push options phase, the environment variables will not be set. If the client selects to use push options, but doesn’t transmit any, the count variable will be set to zero, GIT_PUSH_OPTION_COUNT=0.
So you can prepare your post-receive
hook script like this:
if [ "x${GIT_PUSH_OPTION_COUNT}" = "x0" ] ; then
exec /usr/share/buildbot/contrib/git_buildbot.py --master=172.16.1.1:8989 --auth="***" --category=yaal --project=yaal --repository=yaal "${@}"
fi
2)
According to git-config-receiveadvertisePushOptions:
When set to true, git-receive-pack will advertise the push options capability to its clients. False by default.
So you need to add this configuration on your remote like so:
git config receive.advertisePushOptions true
Or edit your project.git/config manually.
3)
For pushes that you do not want for your post-receive hook to fire simply add dummy push option, like so:
git push -o blah
Using $GIT_PUSH_OPTION_(n)
you can make your pushes even more sophisticated.