Best way to debug git-hooks

孤人 提交于 2019-12-08 14:46:52

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/31291854/best-way-to-debug-git-hooks

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!