Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best way to debug git-hooks

Tags:

What is the best way to debug git-hooks?

The way I prefer is adding statements to add output to a log file. For example, the following.

echo 'post-receive executed' >> hooks.log 

Is there a better approach or way to do logging?

like image 838
Kashif Nazar Avatar asked Jul 08 '15 11:07

Kashif Nazar


1 Answers

This is an old question, but for future readers, one recommendation would be :

Debugging the hook as a shell script

I doubt that it is the script itself which needs to be looked at, however if that turns out to be the case, then the next step is to do what you normally would to debug shell scripts (since that is what the default commit-msg hook is).

I would start by changing the she-bang line from #!/bin/sh to #!/bin/sh -xv and then revel in the uber-verbose output as the script is executed when you do a git commit --amend

like image 113
Ashutosh Jindal Avatar answered Oct 18 '22 00:10

Ashutosh Jindal