66
77# GitHooks
88
9- Installs [ git hooks] ( https://git-scm.com/docs/githooks ) that will run in your
10- Elixir project .
9+ Configure [ git hooks] ( https://git-scm.com/docs/githooks ) in your Elixir
10+ projects .
1111
12- Any git hook type is supported, [ check here the hooks
13- list] ( https://git-scm.com/docs/githooks ) .
12+ Main features are:
13+
14+ * ** Simplicity** : Automatic or manually install the configured git hook actions.
15+ * ** Flexibility** : You choose what to use to define the git hooks actions:
16+ * Bash commands
17+ * Executable files
18+ * Elixir modules
19+ * ** No limits** : Any git hook is and will be supported out of the box,
20+ you can [ check here the git hooks list] ( https://git-scm.com/docs/githooks ) available.
1421
1522## Table of Contents
1623
17- <!-- vim-markdown-toc Marked -->
24+ <!-- vim-markdown-toc GFM -->
1825
1926* [ Installation] ( #installation )
2027 * [ Backup current hooks] ( #backup-current-hooks )
@@ -26,6 +33,7 @@ list](https://git-scm.com/docs/githooks).
2633 * [ Type of tasks] ( #type-of-tasks )
2734 * [ Command] ( #command )
2835 * [ Executable file] ( #executable-file )
36+ * [ Elixir module] ( #elixir-module )
2937* [ Removing a hook] ( #removing-a-hook )
3038* [ Execution] ( #execution )
3139 * [ Automatic execution] ( #automatic-execution )
@@ -51,8 +59,8 @@ mix deps.get && mix deps.compile
5159
5260### Backup current hooks
5361
54- This project will backup automatically your the hook files that are going to be
55- overwrite .
62+ This library will backup automatically your current git hooks before
63+ overwriting them .
5664
5765The backup files will have the file extension ` .pre_git_hooks_backup ` .
5866
@@ -159,6 +167,31 @@ config :git_hooks,
159167The script file executed will receive the arguments from git, so you can use
160168them as you please.
161169
170+ #### Elixir module
171+
172+ It is also possible to use Elixir modules to execute actions for a given git
173+ hook.
174+
175+ It is recommended the module implement the behaviour ` GitHooks ` first and then
176+ add your config as a
177+ [ MFA] ( https://hexdocs.pm/elixir/typespecs.html#built-in-types ) (`{module,
178+ function, arity}`):
179+
180+ ``` elixir
181+ config :git_hooks ,
182+ verbose: true ,
183+ hooks: [
184+ commit_msg: [
185+ tasks: [
186+ {MyModule , :execute , 2 }
187+ ]
188+ ]
189+ ]
190+ ```
191+
192+ To see which arguments a git hook receives, [ check the git
193+ documentation] ( https://git-scm.com/docs/githooks ) .
194+
162195## Removing a hook
163196
164197When a git hook configuration is removed, the installed hook will automatically
0 commit comments