#hook #cargo-toml #pre-commit #execute #metadata #read #workspace

pre-commit-hooks

Reads hooks metadata from Cargo.toml and executes on commit. Works with workspace format.

1 unstable release

Uses old Rust 2015

0.3.0 Jun 5, 2023
0.2.0 May 3, 2023
0.1.1 Apr 30, 2023
0.1.0 Apr 30, 2023

#15 in #pre-commit

Download history 18/week @ 2024-06-28 35/week @ 2024-07-05 34/week @ 2024-07-12 33/week @ 2024-07-19 44/week @ 2024-07-26 43/week @ 2024-08-02 42/week @ 2024-08-09 19/week @ 2024-08-16 26/week @ 2024-08-23 23/week @ 2024-08-30 13/week @ 2024-09-06 29/week @ 2024-09-13 58/week @ 2024-09-20 31/week @ 2024-09-27 31/week @ 2024-10-04 38/week @ 2024-10-11

161 downloads per month

MIT license

7KB
121 lines

pre-commit-hooks

Reads hooks metadata from Cargo.toml and executes on commit. A forked from unmaintained pre-commit.

Installing

[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.

Usage

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.

Credit

The find_crate_root function is refactored with the help of emilgardis.

No runtime deps

~53KB