Skip to content

nentgroup/pre-commit-hooks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Languages