swellaby / rusty-hook

git hook manager, geared toward Rust projects
MIT License
206 stars 11 forks source link

How to pass git arguments to command? #113

Closed Absolucy closed 3 years ago

Absolucy commented 3 years ago

Question Hi, I'm trying to use rusty-hook to enforce conventional commit messages, using the commit-msg hook. However, it doesn't seem to pass the git args to my script?

calebcartwright commented 3 years ago

Thanks for the question @aspenluxxxy! This isn't readily available at the moment unfortunately.

Git hook utilities that follow the approach rusty-hook does don't want to just tack on git args to the configured hook script because in many/most cases that'd cause errors (you wouldn't want to throw git args at cargo check or cargo clippy for example). Instead, it's common for the git args to be made available as an environment variable (node/npm's husky for example uses HUSKY_GIT_PARAMS), which your hook scripts/tools/etc. can than leverage.

Making the git params available as an env is being tracked under #25 if you'd like to track that issue.

Absolucy commented 3 years ago

Ah, I was wondering if there was a way to use a replace (like having {ARGS} in the command)

Absolucy commented 3 years ago

I may try to contribute :+1:

calebcartwright commented 3 years ago

I may try to contribute +1

That would be fantastic thank you! There's one minor update I need to make to a lib rusty-hook uses, but after that the changes needed here should be pretty straightforward. The actual git hook files are already passing the git args to the rusty-hook cli, it's just that rusty-hook isn't doing anything with them yet :laughing:

https://github.com/swellaby/rusty-hook/blob/7f2eb4b519bd93b558e140813b7fdf37aec4a491/src/hook_files/hook_script.sh#L24