Conditionally run hooks based on staged files #3

Closed
opened 2022-11-01 10:17:07 +00:00 by Bauke · 1 comment
Owner

A way to only run a hook when Git has certain files staged.

For example, only run cargo test when .rs files have changed:

[[pre_commit]]
command = "cargo test"
git_staged = ["*.rs"]

To get Git's staged files:

git diff --name-only --cached

Using globset this should be pretty easy to add.

A way to only run a hook when Git has certain files staged. For example, only run `cargo test` when `.rs` files have changed: ``` [[pre_commit]] command = "cargo test" git_staged = ["*.rs"] ``` To get Git's staged files: ```sh git diff --name-only --cached ``` Using [globset](https://docs.rs/globset) this should be pretty easy to add.
Bauke added this to the Version 0.2.0 milestone 2022-11-01 10:17:07 +00:00
Bauke added the
Feature Request
label 2022-11-01 10:17:07 +00:00
Bauke self-assigned this 2022-11-01 10:17:07 +00:00
Author
Owner

Added to config in da0e38e3bb and CLI in 651699c40a.

Added to config in da0e38e3bb4447871bf1cce819e57278c43cd411 and CLI in 651699c40aeff48c6af797c7182bcd3f83171d31.
Bauke closed this issue 2022-11-20 11:46:17 +00:00
Bauke added the
Completed
label 2022-11-20 11:46:23 +00:00
Sign in to join this conversation.
No description provided.