Skip to content

Collection of useful git-hooks. Conditional processing handled by python scripts.

License

Notifications You must be signed in to change notification settings

Coombszy/git-hooks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

git-hooks

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.

Features

  • 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)

Installation

To install the hooks, run the following command from the root of the repository:

git config --global core.hooksPath "$(pwd)/hooks"

Configuration

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.

Supported Tools & Requirements

All tools must be available on the PATH:

  • Python:
  • Terraform:
    • Terraform - Format and validate Terraform infrastructure as code
    • TFLint - Terraform linting
  • Rust:
    • Rustfmt - Code formatting (included with cargo)
    • Clippy - Linting (included with cargo)
  • CloudFormation:
    • cfn-lint - CloudFormation template validation
  • Shell:
  • Git:
    • Blocking text - Prevent commit if changes contain BLOCK-COMMIT, BLOCK_COMMIT, BLOCK COMMIT

Useful Git Aliases

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 hooks
  • git configure-hooks - Edit your hooks configuration (git config core.editor must be set!)

About

Collection of useful git-hooks. Conditional processing handled by python scripts.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published