rhysd / cargo-husky

Setup Git hooks automatically for cargo projects with :dog:
https://crates.io/crates/cargo-husky
MIT License
321 stars 20 forks source link

Improve documentation: how to apply feature changes #30

Open sbeyer opened 3 years ago

sbeyer commented 3 years ago

For cargo-husky users that are new to Rust and the cargo system, it might be unclear how to let updated cargo-husky feature changes in Cargo.toml also update the Git hooks.

For example, perform the following steps:

  1. add
    [dev-dependencies.cargo-husky]
    version = "1"
    features = ["precommit-hook", "run-cargo-clippy"]

    to Cargo.toml

  2. invoke cargo test
  3. notice that .git/hooks/pre-commit contains cargo clippy :+1:
  4. add "run-cargo-fmt" to the features in Cargo.toml
  5. invoke cargo test
  6. notice that .git/hooks/pre-commit does not contain cargo fmt :-1:

My request is to update the README.md to make clear how to "activate" changed feature settings.

xenoterracide commented 3 years ago

I was just going to report this, do you know how to do it?

sbeyer commented 3 years ago

I was just going to report this, do you know how to do it?

Other than cargo clean? No.

xenoterracide commented 3 years ago

hmm... I have this in the root Cargo.toml

[dev-dependencies.cargo-husky]
version = "^1"
default-features = false # Disable features which are enabled by default
features = ["precommit-hook", "run-cargo-fmt", "run-for-all"]
❯ cargo clean                                                                                                                     # brix-rust -> ccushing/copy-1a ! $
❯ cargo test    
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
❯ cat .git/hooks/pre-commit                                                                                                         # brix-rust -> ccushing/copy-1a ! $
[bat error]: '.git/hooks/pre-commit': No such file or directory (os error 2)