gitgit-post-receive

How to test git hooks


Since "testing" is a common use for a Git hook, my question is hard to search for.

I'm writing a fairly involved git post-receive hook and want to know what the best way to test it is. Currently my process is:

Is there any easier way to test this? Ideally it would look like:

Perhaps I can "reissue" a previous push or have the remote repo act as though it just received a push with a specific hash?


Solution

  • Write a hook that just records its arguments/environment and dumps that to a file. Then you can just re-invoke the real hook at your leisure with the same environment/arguments and it will act as though you just re-issued the exact same push.