In a bash script I do a
git push
and I check its exit status.
On the remote server there's a post-receive hook which does a few things. If an error occurs the post-receive hook will exit with a non-zero value.
However when the post-receive hook errors out, git push exits normally. Unless I'm specifically checking the output for specific error strings (which I'm not) my script thinks everything went ok.
Is there an easy way for me to determine if the post-receive hook failed?
So the answer is no there is no way to easily check if the post-receive hook failed. The best you can do is have your script check for output from remote and make sure your post-receive hook echos an error message you're looking for.
In my case a pre-receive hook won't work since I'm pushing to another backup repo and the new commit has to be accepted before it can be pushed.
Basically the post-receive hook should do something like:
some-command-that-might-fail
RC=$?
if [ $RC -eq 0 ]; then
echo -e "\nERROR: some-command-that-might-fail FAILED!!!!!!!! PANIC!!!!!!\n"
fi
Then the script doing the push should grep the output for FAILED or ERROR or PANIC and report the post-receive error.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With