Crates.io | pre-commit-hooks |
lib.rs | pre-commit-hooks |
version | 0.3.0 |
source | src |
created_at | 2023-04-30 22:19:43.410695 |
updated_at | 2023-06-05 12:49:49.767968 |
description | Reads hooks metadata from Cargo.toml and executes on commit. Works with workspace format. |
homepage | |
repository | https://github.com/nentgroup/pre-commit-hooks |
max_upload_size | |
id | 853045 |
size | 7,325 |
Reads hooks metadata from Cargo.toml
and executes on commit. A forked from unmaintained pre-commit.
[dependencies]
pre-commit-hooks = "0.3"
For a workspace-based setup, one only need to add it in one of the package dependency, usually the main package (if any). This is because the pre-commit applies to the whole project.
Add a table like the following to your root Cargo.toml
:
[package.metadata.precommit]
fmt = "cargo fmt"
sort = "cargo sort"
Or, if you're ussing workspace:
[workspace.metadata.precommit]
fmt = "cargo fmt"
sort = "cargo sort -w"
Then run:
$ cargo clean
$ cargo build
You should now have a pre-commit
file in your ./git/hooks
that will run the listed pre-commit entries.
The find_crate_root
function is refactored with the help of emilgardis.