| Crates.io | rusty-hooks-integration |
| lib.rs | rusty-hooks-integration |
| version | 0.12.0 |
| created_at | 2025-06-08 19:31:33.051846+00 |
| updated_at | 2025-06-08 19:31:33.051846+00 |
| description | git hooks integration for Rust projects |
| homepage | |
| repository | https://github.com/kaimast/rusty-hooks |
| max_upload_size | |
| id | 1705199 |
| size | 117,517 |
Git hook utility for Rust codebases that lets you run any script for any git hook.
This is a fork of rusty-hook which seems to be unmaintained.
Pre-requisites: Make sure you have Rust installed and that Cargo's bin directory is on your PATH. https://www.rust-lang.org/tools/install
rusty-hooks as a dev dependency in your Cargo.toml filecargo test (to build your dev dependencies, including rusty-hooks).rusty-hooks.toml file with the commands you want to rungit commit (or equivalent to trigger your git hook)!
cargo test) to see the hooks be enforced.Just add rusty-hooks-integration as a dev dependency in your Cargo.toml file:
[dev-dependencies]
rusty-hooks-integration = "0.12"
When you add rusty-hooks as a dev-dependency in your project, it will automatically configure the git hooks once it is built (for example the first time you run cargo test).
This will ensure that all of the client side git hooks are setup and available, and it will create a rusty-hooks configuration file if one does not already exist.
The git hook script will ensure that the rusty-hooks cli is available, so the very first time a git hook is triggered on your machine you will see a message indicating that the rusty-hooks setup is being finalized which may take ~30 seconds or so:
Finalizing rusty-hooks configuration...
This may take a few seconds...
You can also install the rusty-hooks cli with cargo:
cargo install rusty-hooks
Or you can directly install it from source
cargo install --path=cmd
You can optionally manually initialize any git directory by running the init command in any git directory to set it up:
rusty-hooks init
You define your desired git hook configuration in the rusty-hooks configuration file (a TOML file named .rusty-hooks.toml or rusty-hooks.toml).
Here's an example rusty-hooks configuration that leverages multiple git hooks, including the pre-commit and the pre-push hooks:
[hooks]
pre-commit = "cargo test"
pre-push = ["cargo check", "cargo fmt -- --check"]
post-commit = "echo yay"
[logging]
verbose = true
Under the [hooks] table, you can add an entry for any and every git hook you want to run by adding a key using the name of the git hook, and then specify the command/script you want to run for that hook. Multiple commands in a form of a toml array or via command chaining using && are also allowed (Only for versions 0.12 and up). Whenever that git hook is triggered, rusty-hooks will run your specified command!
In git hook commands, any instance of %rh! will be replaced by the arguments that git passes to this hook.
[hooks]
pre-push = "echo %rh!"
Under the [logging] table, you can control whether to log the output of running your specified hook commands. By default rusty-hooks will log the results of your hook script, but you can disable this behavior by setting the verbose key to false:
[logging]
verbose = false
There's a few other git hook utilities available on crates.io, but none of them quite suited our needs so we made rusty-hooks!
Note: all of these seem to be unmaintained.
All contributions are welcome and appreciated! Check out our Contributing Guidelines for more information about opening issues, developing, and more.
We'll be sad to see you go, but here's what to do if you'd like to remove rusty-hooks from your project.
rusty-hooks dev dependency from the Cargo.toml file in your project..rusty-hooks.toml configuration file from your project..git/hooks/ directory). Note that if you were using rusty-hooks version 0.9.1 or newer and you skip this step, then the git hooks will still be invoked as part of your git workflow and you will see the following warning message on git commit:rusty-hooks git hooks are configured, but no config file was found
In order to use rusty-hooks, your project must have a config file
See https://github.com/kaimast/rusty-hooks#configure for more information about configuring rusty-hooks
If you were trying to remove rusty-hooks, then you should also delete the git hook files to remove this warning
See https://github.com/kaimast/rusty-hooks#removing-rusty-hook for more information about removing rusty-hooks from your project
Please also consider opening an issue to report any bugs/problems you experienced, missing features, etc. so that we can work on improving rusty-hooks!