hookz

command module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 4, 2021 License: MIT Imports: 2 Imported by: 0

README

hookz

Manages commit hooks inside a local git repository based on a configuration.

Configuration

Hookz uses a configuration file to generate hooks in your local git repository. This file needs to be in the root of your repository and must be named .hooks.yaml

Take for example the following configuration:

  hooks:
  - name: "PlantUML Image Generator"
    type: pre-commit
    url: https://github.com/jjimenez/pre-plantuml
    args: [deflate]
  - name: "Post-Commit Echo"
    type: post-commit
    exec: derp
    args: ["Hello World"]

Hooks will read this configuration and create a pre-commit hook and a post-commit hook based on this yaml.

The pre-commit will download the binary from the defined URL and configure the pre-commit to execute the command with the defined arguments before a commit happens.

The post-commit in this configuration will execute a command named "derp" with the arguments "Hello World" after a commit has occurred. Note that the derp command must be on your path. If it isn't this post-commit will fail because the command isn't found.

Return Codes

Any non-zero return code from a command executed in a hook will return a FAIL.

Running Hookz

To generate the hooks as defined in your configuration simply execute the following:

hookz init

Removing hooks can be done by executing the following command:

hookz remove

Example Hooks

Pull from your remote branch before committing
  - name: "Git Pre-Commit Pull"
    type: pre-commit
    exec: git
    args: [pull]

TODO

  • Create a verbose flag that doesn't eat command error messages
  • Allow for multiple type actions
  • Download binary from URL and make executable in the .git/hooks directory

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
Package cmd contains all of the commands that may be executed in the cli
Package cmd contains all of the commands that may be executed in the cli

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL