| Crates.io | husky-rs |
| lib.rs | husky-rs |
| version | 0.2.2 |
| created_at | 2024-09-28 15:45:27.632362+00 |
| updated_at | 2026-01-09 10:10:43.994681+00 |
| description | Git hooks manager for Rust projects - automatically install and manage Git hooks on build |
| homepage | https://github.com/pplmx/husky-rs |
| repository | https://github.com/pplmx/husky-rs |
| max_upload_size | |
| id | 1390191 |
| size | 122,893 |
husky-rs is a Git hooks management tool for Rust projects, inspired by Husky.
cargo build or cargo testcargo clean when updating hookshusky init, husky add, husky list commandsAdding husky-rs to your project:
You have several options:
# Option 1: Add as a Regular Dependency
cargo add husky-rs
# Option 2: Add as a Dev Dependency
cargo add --dev husky-rs
# Option 3: Use the Main Branch
cargo add --git https://github.com/pplmx/husky-rs --branch main
cargo add --dev --git https://github.com/pplmx/husky-rs --branch main
Create hooks directory:
mkdir -p .husky/hooks
Add a hook (e.g., pre-commit):
echo '#!/bin/sh\necho "Running pre-commit hook"' > .husky/hooks/pre-commit
Install hooks:
cargo build
Or if you're using as a dev-dependency:
cargo test
Tip: If you add this library to the [dependencies] section, both cargo build and cargo test will work. However, if it's added under [dev-dependencies], only cargo test will function as expected.
husky-rs supports all 27 Git hooks, including:
pre-commit - Run before commit is createdprepare-commit-msg - Edit commit message before committingcommit-msg - Validate commit message formatpost-commit - Run after commit is createdpre-push - Run before pushing to remoteFor a complete list, refer to the Git documentation.
If you encounter any unsupported hooks, please open an issue.
To skip hook installation (useful in CI environments):
NO_HUSKY_HOOKS=1 cargo build
You can also set this in your environment or CI configuration.
For added convenience, install the husky command-line tool:
cargo install husky-rs --features=cli
The CLI provides helpful commands:
husky init # Create .husky/hooks directory
husky add pre-commit # Add hook from smart template
husky list # List all installed hooks
husky help # Show help
Note: The CLI is completely optional - the core functionality works without it!
For advanced use cases, husky-rs exposes utility functions:
use husky_rs::{hooks_dir, should_skip_installation, is_valid_hook_name};
// Check if hook installation should be skipped
if !should_skip_installation() {
let hooks_path = hooks_dir(".");
println!("Hooks directory: {}", hooks_path.display());
}
// Validate a hook name
if is_valid_hook_name("pre-commit") {
println!("Valid hook!");
}
See API documentation for more details.
Note: You don't need to call any functions for basic usage - just add the dependency!
📖 Complete guides for all users:
We welcome contributions! Please see our Contributing Guide for details on how to submit pull requests, report issues, or suggest improvements.
This project is licensed under either of:
at your option.
For a detailed history of changes to this project, please refer to our CHANGELOG.md.