Rhusky
Git hooks manager for Rust projects. Like Husky, but for Rust.
Inspired by Sloughi and the Node.js Husky project.
Why Rhusky?
- Truly idempotent: Never overwrites your existing hook scripts
- No magic: Just sets
core.hooksPathin git config - CI-aware: Skips installation in CI environments
- Zero dependencies: Pure Rust, no external crates
Installation
Add rhusky to your build-dependencies:
[]
= "0.0.1"
Create a build.rs file at the root of your project:
Create your hooks directory and add your hooks:
Configuration
Custom hooks directory
new
.hooks_dir // default is ".githooks"
.install
.ok;
Skip in CI environments
By default, installation is skipped when the CI environment
variable is set. Add more:
new
.skip_in_env
.skip_in_env
.install
.ok;
How it works
Rhusky sets Git's core.hooksPath configuration to point to your
hooks directory. This tells Git to look for hooks in that directory
instead of the default .git/hooks/.
Unlike other tools, Rhusky:
- Never creates hook files - you manage your own hooks
- Never overwrites existing files - truly idempotent
- Only sets git config - minimal, predictable behavior
Recommended hooks
pre-commit
#!/bin/sh
commit-msg
#!/bin/sh
# Verify conventional commit format with Cocogitto
if ; then
fi
Comparison with similar tools
| Feature | Rhusky | Sloughi | cargo-husky | husky-rs |
|---|---|---|---|---|
Sets core.hooksPath |
Yes | Yes | No | No |
| Creates hook files | No | Yes | Yes | Yes |
| Overwrites existing hooks | No | Yes | Yes | Yes |
| Zero dependencies | Yes | Yes | No | No |
| Customizable hooks dir | Yes | Yes | Limited | Limited |
| CI-aware | Yes | Yes | No | No |
Sloughi
Sloughi was the inspiration
for Rhusky. It uses the same core.hooksPath approach but creates
default hook files on every cargo build, overwriting any custom
hooks you've written. Rhusky fixes this by never creating or
modifying hook files.
cargo-husky
cargo-husky copies hook
scripts into .git/hooks/ rather than using core.hooksPath. This
means hooks aren't easily shareable via version control and can
conflict with other tools that manage .git/hooks/.
husky-rs
husky-rs also copies hooks
into .git/hooks/. Like cargo-husky, it doesn't use the modern
core.hooksPath approach and overwrites existing hooks.
