husky-rs
is a Git hooks management tool for Rust projects, inspired by Husky.
- Easy setup and configuration
- Automatic installation of Git hooks
- Support for all Git hooks
- Cross-platform compatibility (Unix-like systems and Windows)
-
Add to your
Cargo.toml
:[dev-dependencies] husky-rs = "0.1.1"
-
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:
Note: Due to the execution mechanism of
build.rs
, runningcargo clean
is required when installing or updating hooks.cargo clean && 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 Git hooks, including:
pre-commit
prepare-commit-msg
commit-msg
post-commit
pre-push
For a full list, see the Git documentation.
To skip hook installation:
NO_HUSKY_HOOKS=1 cargo build
- Keep hooks lightweight to avoid slowing down Git operations
- Use hooks for tasks like running tests, linting code, and validating commit messages
- Non-zero exit status in a hook script will abort the Git operation
For information on setting up the development environment, running tests, and contributing to the project, please refer to our Development Guide.
If you encounter any issues while using husky-rs
, please check our Troubleshooting Guide for common problems and their solutions. If you can't find a solution to your problem, please open an issue on our GitHub repository.
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:
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
For a detailed history of changes to this project, please refer to our CHANGELOG.md.
- Inspired by cargo-husky
- Thanks to the Rust community for their amazing tools and libraries