swellaby / rusty-hook

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

Make git params available as environment variable #25

Closed calebcartwright closed 4 years ago

calebcartwright commented 5 years ago

Description

rusty-hook should take the git params and expose them as an environment variable

Value

This would make those git params accessible to the downstream tools/scripts that are invoked by rusty-hook

calebcartwright commented 4 years ago

For anyone interested in working on this, a couple recent PRs have made it really simple to deliver this feature with a small final amount of work.

Basically, we just need to change the final arg from None to an option-wrapped HashMap reference that uses RUSTY_HOOK_GIT_PARAMS for the key and the value would be the args parameter in the run function (currently _args because it's not used yet).

https://github.com/swellaby/rusty-hook/blob/755cd4477d141cebc084186ebc4c33828caba604/src/rusty_hook.rs#L116

Could also consider tweaking the cli to keep the Option<String> and passing that along to run, and conditionally set the value passed to run_command based on whether args is None or Some, with None and the HashMap respectively

https://github.com/swellaby/rusty-hook/blob/755cd4477d141cebc084186ebc4c33828caba604/src/main.rs#L74 https://github.com/swellaby/rusty-hook/blob/755cd4477d141cebc084186ebc4c33828caba604/src/main.rs#L47