10 stable releases
Uses new Rust 2024
new 1.5.0 | Apr 28, 2025 |
---|---|
1.4.3 | Apr 28, 2025 |
0.2.1 | Apr 21, 2025 |
0.1.1 | Apr 21, 2025 |
#1241 in Command line utilities
790 downloads per month
37KB
642 lines
๐ช Hooksmith
,"( . ////\ / (//////--,,,,,_____ ," _;"""----/////_______;,, // __________;"o,-------------......"""""`'-._/( ""'==._.__,;;;;""" ____,.-.== "-.:______,...;---""/" " \( '-._ `-._(" \\ '-._ '._
Git Hook Management Made Simple
Hooksmith is a lightweight, easy-to-use tool that simplifies Git hook management. Define your hooks in a simple YAML file and let Hooksmith handle the rest.
๐ Table of Contents
- โจ Features
- โก Why Hooksmith?
- ๐ง Installation
- ๐ Quick Start
- ๐ Usage
- ๐ Command Reference
- ๐ค Contributing
- ๐ License
โจ Features
- โ๏ธ Automatic Installation - Set up hooks through your build scripts with
build.rs
- ๐งช Local Testing - Run hooks manually without triggering Git events
- ๐ Dry Run Mode - Preview what would happen without making changes
- โ Hook Validation - Ensure your hooks comply with Git standards
- ๐ Simple Configuration - Define all your hooks in a clean YAML format
โก Why Hooksmith?
- Minimal Dependencies - Lightweight with only essential dependencies
- Rust Powered - Fast, reliable, and type-safe
- Team Friendly - Version control your hook configurations
- Seamless Integration - Works naturally with your Git workflow
- Low Learning Curve - Simple commands and clear documentation
๐ง Installation
Using Cargo
cargo install hooksmith
As a Build Dependency
Add to your Cargo.toml
:
[build-dependencies]
hooksmith = "1.4.3"
Create a build.rs
file:
use std::path::Path;
fn main() {
let config_path = Path::new("hooksmith.yaml");
hooksmith::init(&config_path);
}
๐ก Note: Hooksmith includes shell completions for Fish. After installation, they become available automatically.
๐ Quick Start
- Create a
hooksmith.yaml
file in your project root:
pre-commit:
commands:
- cargo fmt --all -- --check
- cargo clippy -- --deny warnings
pre-push:
commands:
- cargo test
- Install the hooks:
hooksmith install
That's it! Your Git hooks are now ready to use.
๐ Usage
Configuration File
Hooksmith uses a YAML configuration file (default: hooksmith.yaml
) to define your hooks:
# Format and lint code before committing
pre-commit:
commands:
- cargo fmt --all -- --check
- cargo clippy --workspace --all-features -- --deny warnings
# Run tests before pushing
pre-push:
commands:
- cargo test --all-features
- cargo build --verbose
# Validate commit messages
commit-msg:
commands:
# Use custom script to validate commit messages
- ./scripts/verify-commit-message.sh $1
Common Commands
# Install all hooks defined in configuration
hooksmith install
# Run a specific hook manually
hooksmith run pre-commit
# Uninstall all hooks or a specific one
hooksmith uninstall
hooksmith uninstall pre-commit
# Compare installed hooks with configuration
hooksmith compare
# Validate hook configuration against Git standards
hooksmith validate
Add --dry-run
to any command to preview changes without applying them:
hooksmith install --dry-run
๐ Command Reference
Command | Description |
---|---|
install |
Install all hooks from configuration file |
run <hook> |
Run a specific hook manually |
uninstall [hook] |
Uninstall all hooks or a specific one |
compare |
Compare installed hooks with configuration |
validate |
Validate hook configuration against Git standards |
Global Options
Option | Description |
---|---|
--config-path <PATH> |
Specify a custom configuration file path |
--dry-run |
Preview changes without applying them |
--verbose |
Show detailed output during execution |
--help |
Display help information |
๐ค Contributing
Contributions are welcome! Feel free to:
- Report bugs and suggest features
- Submit pull requests
- Improve documentation
- Share your use cases and feedback
๐ License
This project is dual-licensed under either:
at your option.
Dependencies
~2.7โ3.5MB
~71K SLoC