Skip to main content

Introducing Captain Hook

This blog post might be outdated!
This blog post was published more than one year ago and might be outdated!
· 2 min read
Stephan Hochdörfer
Head of IT Business Operations

Back at MageTestFest in Florence, I introduced the audience to a tool called Captain Hook for managing Git hooks. In the QA section of my talk, the question was raised why I have not recommended to use GrumPHP. A valid question since all the QA tools I talked about are already supported by GrumPHP out-of-the-box.

Despite Captain Hook being an awesome name, I like the flexibility it comes with. Whilst GrumPHP can hook itself into the pre-commit and commit-msg hooks, Captain Hook provides support for the following hooks: commit-msg, pre-push, pre-commit, prepare-commit-msg, post-commit, post-merge. This means I don't need to run longer running tasks as pre-commit hook but can hook in those tasks as pre-push hook, for example. Giving me quick feedback on local commits, but still allowing me to make sure that certain checks are executed before pushing the code to a remote git server.

In addition to that, adding external tools is a lot easier in CaptainHook than compared to GrumPHP. In GrumPHP you need to edit a YAML file and add a PHP class which will call the external tool. When adding an external tool to Captain Hook, just add the cli command to the captainhook.json file and you are done.

However, there's a way to use both tools the same time. My colleague Andreas Heigl built a plugin for Captain Hook to allow the execution of GrumPHP taks. Maybe you to want to give it a try. ARRRR!