Git Hooks
This document is a guide on how to add coala as a git hook. Using a git hookcoala can be executed automatically, ensuring your code follows your qualityrequirements.
Pre-Commit Hooks
The pre-commit hook can be used to run coala before every commit action.Hence, this does not allow any code not following the quality standardsspecified unless it’s done by force.
To enable this, just create the file .git/hooks/pre-commit
under yourrepository and add the lines:
- #!/bin/sh
- set -e
- coala
You can also specify arguments like -S autoapply=false
which tellscoala to not apply any patch by itself. Or you can run specific sections withcoala <section_name>
.
See also
- Module Tutorial for Users
- Documentation on how to run coala which introduces the CLI arguments.
- Module coafile Specification
- Documentation on how to configure coala using the coafilespecification.
Note
If you allow coala to auto apply patches, it’s recommended to add*.orig to your .gitignore. coala creates these files while applyingpatches and they could be erroneously added to your commit.
This file needs to be executable. If it is not (or if you aren’t sure), youcan make it executable by running
- $ chmod +x .git/hooks/pre-commit
and you’re done! It will run every time before you commit, and preventyou from committing if the code has any errors.