This repository provides a configurable git hooks system with support for multiple languages and tools. The hooks are dynamically configured based on file types detected in your repository.
- Configurable targets: Enable/disable hooks for different languages and tools
- Automatic file type detection: Hooks only run when relevant files are detected
- Parallel execution: Scripts run concurrently for better performance
- Multi-language support: Python, Rust, Terraform, Shell, CloudFormation, and Git
- Local repository integration: Automatically detects and runs local pre-commit configurations (e.g., npm husky)
To install the hooks, run the following command from the root of the repository:
git config --global core.hooksPath "$(pwd)/hooks"The hooks are configured via config/config.json. If this file doesn't exist, it will be created automatically from config/config.json.example on first run.
By default, all language/tool targets are disabled except Git hooks (e.g. block-commit.sh). You need to explicitly enable the tools you want to use by setting "enabled": true in your configuration file.
All tools must be available on the PATH:
- Python:
- Black - Code formatting
- Prospector - Static analysis
- Terraform:
- Rust:
- CloudFormation:
- cfn-lint - CloudFormation template validation
- Shell:
- ShellCheck - Shell script analysis
- Git:
- Blocking text - Prevent commit if changes contain
BLOCK-COMMIT,BLOCK_COMMIT,BLOCK COMMIT
- Blocking text - Prevent commit if changes contain
Here are some helpful git aliases to make working with this hooks system easier:
# Test pre-commit hooks without actually committing
git config --global alias.pre-commit "! $(git config --global core.hooksPath)/pre-commit; echo 'Just kidding!'"
# Open the hooks configuration file in your default editor
git config --global alias.configure-hooks "! \"$(git config --global core.editor)\" \"$(git config --global core.hooksPath)/../config/config.json\""After setting these up, you can use:
git pre-commit- Test your pre-commit hooksgit configure-hooks- Edit your hooks configuration (git configcore.editormust be set!)