Closed x80486 closed 4 years ago
I can join the commands I guess, but it would be clear to accept an array and execute them
Yeah for now your best bet will be to join them cargo test --all && cargo build --release
or to include a script on your repo and set the hook to pre-push = "sh awesomeness.sh"
.
It's a reasonable request though and definitely something we'd consider, although I'm not sure we'll have enough bandwidth to get around to this any time soon (PR would be welcome!)
@calebcartwright I might have some time this week to work on this. I haven't worked with the repo at all yet so a small pointer on where to start would be nice. For now I would just implement this very simple. Taking the arguments and just joining them together using a &&
. What do you think?
@Mastermindaxe that would be fantastic, thanks so much!
Taking the arguments and just joining them together using a &&. What do you think?
That'll work just fine. We need to support both a simple string hook specification as well as an array, where the latter really just makes things easier/more human friendly in the toml file, but
pre-commit = "cargo fmt -- --check && cargo clippy"
should functionally be the same as
pre-commit = [
"cargo fmt -- --check",
"cargo clippy",
]
I haven't worked with the repo at all yet so a small pointer on where to start would be nice.
It's been a little while since I've been in there but I think you'd likely want to start here: https://github.com/swellaby/rusty-hook/blob/7f2eb4b519bd93b558e140813b7fdf37aec4a491/src/config.rs#L155-L163
Could probably just do a match directly against the toml::Value variants, for example
pub fn get_hook_script(config_contents: &str, hook_name: &str) -> Result<String, String> {
match get_table_key_value_from_config(config_contents, "hooks", hook_name)? {
Value::Array(val) => { ..... }
Value::String(val) => Ok(val),
_ => Err(String::from("Invalid hook config")),
}
}
Feel free to open an early/draft PR if you have any questions as well!
Closing as the feature's been implemented, should be released in v0.12
Description
I started using
rusty-hook
recently. I have everything configured now, but I can't execute multiple commands for a given Git hook, for instance:That's what I'm trying to achieve, but the configuration file is invalid. Is it possible to allow multiple actions/commands when a given Git hook is triggered?
Value
Sometimes we would like to do several actions/things when a Git hook is triggered. Currently that's not possible, or at least in the way I would expect it to work. I can join the commands I guess, but it would be clear to accept an array and execute them.