Handy Git hooks to integrate with pre-commit framework.
-
Available hooks
NOTE: hooks require Python 3.
Add .pre-commit-config.yaml
config file to in your project:
- repo: https://github.com/MarcinOrlowski/pre-commit-hooks
rev: 1.0.0 # or any specific git tag
hooks:
- id: checkstyle-jar
# args: [ '--jar=/path/to/checkstyle.jar' ]
- id: end-of-file
# exclude_types: ['xml','png','jpeg','svg']
# args: [ '--fix=yes' ]
- id: trailing-whitespaces
# exclude_types: ['xml','png','jpeg','svg']
# args: [ '--fix=no' ]
If you want to invoke the checks as a git pre-commit hook, run:
$ pre-commit install
If you want to run the checks on-demand (outside of git hooks), run:
$ pre-commit run --all-files --verbose
To try your hooks with all the files present.
NOTE: This will apply your hooks too ALL the files, which in case of using modifying hooks might not what you really want!
- Written and copyrighted ©2021-2022 by Marcin Orlowski <mail (#) marcinorlowski (.) com>
- This is open-sourced software licensed under the MIT license