Skip to content

captainhook-go/captainhook

Repository files navigation

Version Go Report Card Go Version Go Reference

CaptainHook

CaptainHook logo

CaptainHook is an easy to use and very flexible git hook manager for software developers. It enables you to configure your git hook actions in a simple json file and easily share them within your team.

You can use CaptainHook to validate or prepare your commit messages, ensure code quality or run unit tests before you commit or push changes to git. You can automatically clear local caches or install the correct dependencies after pulling the latest changes.

You can run your own commands or use loads of built-in functionality. For more information have a look at the documentation.

Installation

You can download the application binary for your platform from the release page. Or use one of the following options.

Use Homebrew to install CaptainHook.

brew tap captainhook-go/captainhook
brew install captainhook

Use go install to install CaptainHook.

go install github.com/captainhook-go/captainhook/cmd/captainhook@latest

Setup

After installing CaptainHook, navigate to your project directory and use the captainhook init command to create a configuration file.

cd my-project-repo
captainhook init

As soon as you have a configuration file the only thing left is to activate the hooks by installing them to your local .git/hooks directory. To do so just run the following captainhook command.

captainhook install

Configuration

Here's an example captainhook.json configuration file.

{
  "hooks": {
    "commit-msg": {
      "actions": [
        {
          "run": "CaptainHook::Message.MustFollowBeamsRules"
        }
      ]
    },
    "pre-commit": {
      "actions": [
        {
          "run": "unittest"
        }
       ]
    },
    "pre-push": {
      "actions": [
        {
          "run": "CaptainHook::Branch.PreventPushOfFixupAndSquashCommits",
          "options": {
            "branches-to-protect": ["main", "integration"]
          }
        }
      ]
    }
  }
}

Contributing

So you'd like to contribute to CaptainHook? Excellent! Thank you very much. I can absolutely use your help.

Have a look at the contribution guidelines.

About

CaptainHook is a very flexible git hook manager for software developers that makes sharing git hooks with your team a breeze.

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Languages