Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow setting environment variables and map them with specific hook #180

Closed
sudhirdhumal289 opened this issue Dec 25, 2021 · 2 comments
Closed

Comments

@sudhirdhumal289
Copy link

Description

Allow setting environment variables before executing command via hook.

Value

we will be able to execute command which are dependent on environment variable.

@calebcartwright
Copy link
Member

Could you elaborate a bit on the specific use case you have in mind, and why you'd want/need this as opposed to the approaches that are already available today?

I'll take a guess and assume it's because you're trying to run some rather large commands like the one you mentioned in #181? I was originally going to ask why something like:

[hooks]
pre-commit = "FOO=bar cargo test ..."

wouldn't suffice for you, though similar question with the direct exports. Is it a matter of preference/perceived convenience or are you have issues getting the vars set in the context the commands are executed?

Also FWIW, that example is starting to hit the limits of what I'd want to try to specify inline in a toml key value. When the desired command(s) get large enough, I personally think folks would find it easier to utilize additional tooling like cargo make, or even adding a shell script to the repo (just be sure to make it executable on the git index) and set the toml file to

[hooks]
pre-commit = "sh your_committed_shell_script.sh"

@sudhirdhumal289
Copy link
Author

It will more of convenience, as and it will reduce the characters in command nothing more than that.

I already moved my code in shell script. Thnx,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants