GitHooks
Installs git hooks that will run in your Elixir project.
Table of Contents
Installation
Add to dependencies:
def deps do
[{:git_hooks, "~> 0.1.2"}]
endThen install and compile the dependencies:
mix deps.get && mix deps.compileBackup current hooks
This project will backup automatically your the hook files that are going to be overwrite.
The backup files will have the file extension .pre_git_hooks_backup.
Automatic installation
This library will install automatically the configured git hooks in your config.exs file.
Manual installation
You can manually install the configured git hooks at any time by running:
mix git_hooks.installConfiguration
One or more git hooks can be configured, those hooks will be the ones installed in your git project.
Currently there are supported two configuration options:
- mix_tasks: A list of the mix tasks that will run for the git hook
- verbose: If true, the output of the mix tasks will be visible. This can be configured globally or per git hook.
config :git_hooks,
verbose: true,
hooks: [
pre_commit: [
mix_tasks: [
"format"
]
],
pre_push: [
verbose: false,
mix_tasks: [
"dialyzer",
"test"
]
]
]Execution
Supported hooks
Currently, in terms of simplifying the usage of this library, the git hooks are:
- pre_commit
- pre_push
- pre_rebase
- pre_receive
- pre_applypatch
- post_update
Automatic execution
The configured mix tasks will run automatically for each git hook.
Manual execution
You can also run manually any configured git hook as well.
The following example will run the pre_commit configuration:
mix git_hooks.run pre_commitIt is also possible to run all the configured hooks:
mix git_hooks.run all