[![Coverage Status](https://coveralls.io/repos/github/qgadrian/elixir_git_hooks/badge.svg?branch=master)](https://coveralls.io/github/qgadrian/elixir_git_hooks?branch=master)
[![Hex version](https://img.shields.io/hexpm/v/sippet.svg "Hex version")](https://hex.pm/packages/git_hooks)
[![Hex Docs](https://img.shields.io/badge/hex-docs-9768d1.svg)](https://hexdocs.pm/elixir_git_hooks)
[![Build Status](https://travis-ci.org/qgadrian/metadata_plugs.svg?branch=master)](https://travis-ci.org/qgadrian/elixir_git_hooks.svg?branch=master)
[![Deps Status](https://beta.hexfaktor.org/badge/all/github/qgadrian/elixir_git_hooks.svg)](https://beta.hexfaktor.org/github/qgadrian/elixir_git_hooks)
# GitHooks
Installs [git hooks](https://git-scm.com/docs/githooks) that will run in Elixir project.
## Table of Contents
- [Installation](#installation)
- [Backup](#backup-current-hooks)
- [Automatic](#automatic-installation)
- [Manual](#manual-installation)
- [Configuration](#configuration)
- [Execution](#execution)
- [Automatic](#automatic-execution)
- [Manual](#manual-execution)
## Installation
Add to dependencies:
```elixir
def deps do
[{:git_hooks, "~> 0.1.0"}]
end
```
The install the dependencies:
```bash
mix deps.get
```
### Backup current hooks
This project will backup your current git hooks files copying the files and adding the extension `.pre_git_hooks_backup`.
### Automatic installation
This library will install automatically the configured git hooks in your file.
### Manual installation
You can install manually the configured git hooks by running:
```bash
mix git_hooks.install
```
## Configuration
One or more git hooks can be configured, those git hooks will be the ones [installed](#installation) for your project.
Currently there are supported two configuration options:
* **mix_tasks**: A list of the mix tasks that will run for the git hook
* **verbose**: The output of the mix tasks will be visible. This can be configured globally or per git hook.
```elixir
config :git_hooks,
verbose: true,
git_hooks: [
pre_commit: [
mix_tasks: [
"format"
]
],
pre_push: [
verbose: false,
mix_tasks: [
"dialyzer",
"test"
]
]
]
```
## Execution
### Automatic execution
The git hooks will run automatically for each [git step](https://git-scm.com/docs/githooks#_hooks).
### Manual execution
You can run manually any configured git hook as well.
For example, to run the pre_commit configuration:
```bash
mix git_hooks.run pre_commit
```