-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
stdin on hooks #442
Comments
Hi @rafamel,
Maybe. Not sure, if it should be automatic or not. That said, you can enable it locally by creating a # ~/.huskyrc
exec < /dev/tty |
Thanks for getting back @typicode ! Since we're already defining a {
// ...
"husky": {
"interactive": true,
"hooks": {
// ...
}
}
} |
I believe this is because husky is always calling @typicode's workaround solved it for me, but I'm left with the same question as @rafamel: this is something that could be configurable per project |
Ye, doesn't make sense for every developer to add a |
Hello, I wrote an npm package, I guess you could also have husky run a shell script that does File issues or contribute to the GitHub repo |
Related to #597 (comment) This work with GitKraken, SourceTree, Atom, VisualStudio Code : # Used to fix GitKraken bug that launch git hook in terminal
PARENT_COMMAND="$(basename "$(ps -o comm= $PPID)")"
# Check if stdout is a terminal and parent command is `git`
if [ -t 1 ] && [ "$PARENT_COMMAND" == "git" ]; then
# Exec node binary with /dev/tty (current terminal) as stdin
exec < /dev/tty
else
```
And maybe we can add the `HUSKY_GIT_STDIN=1` option |
Let hooks receive user input if applicable. Closing stdin originates in f5bbc32 (Port git commit to C, 2007). Looks like the original shell implementation did have stdin open. Not clear why the author chose to close it on the C port (maybe copy&paste). Some references of users requesting this feature. Some of them use acrobatics to gain access to stdin: [1] https://stackoverflow.com/q/1067874/764870 [2] https://stackoverflow.com/q/47477766/764870 [3] https://stackoverflow.com/q/3417896/764870 [4] PHP-CS-Fixer/PHP-CS-Fixer#3165 [5] typicode/husky#442
Let hooks receive user input if applicable. Closing stdin originates in f5bbc32 (Port git commit to C, 2007). Looks like the original shell implementation did have stdin open. Not clear why the author chose to close it on the C port (maybe copy&paste). The only hook that passes internal information to the hook via stdin is pre-push, which has its own logic. Some references of users requesting this feature. Some of them use acrobatics to gain access to stdin: [1] https://stackoverflow.com/q/1067874/764870 [2] https://stackoverflow.com/q/47477766/764870 [3] https://stackoverflow.com/q/3417896/764870 [4] PHP-CS-Fixer/PHP-CS-Fixer#3165 [5] typicode/husky#442
Let hooks receive user input if applicable. Closing stdin originates in f5bbc32 (Port git commit to C, 2007). Looks like the original shell implementation did have stdin open. Not clear why the author chose to close it on the C port (maybe copy&paste). The only hook that passes internal information to the hook via stdin is pre-push, which has its own logic. Some references of users requesting this feature. Some of them use acrobatics to gain access to stdin: [1] https://stackoverflow.com/q/1067874/764870 [2] https://stackoverflow.com/q/47477766/764870 [3] https://stackoverflow.com/q/3417896/764870 [4] PHP-CS-Fixer/PHP-CS-Fixer#3165 [5] typicode/husky#442 Signed-off-by: Orgad Shaneh <orgads@gmail.com>
Closing as husky 5 is working differently and may not have this issue |
I upgraded to husky 7 hoping it would make interactive hooks work, but it seems all calls to Is there a better solution? Either way, finding out how to add interactive hooks wasn't trivial, maybe it should be added to the docs somewhere? |
Hi, I found myself adding some stdin dependent hooks and just noticed 1.3.1 disables it due to a bug on Windows. Is there a fix planned in the near future? Otherwise, would it be sensible to enable it for other OS and leave it disabled on Windows until a fix is available?
Thanks for the amazing work!
Rafa
The text was updated successfully, but these errors were encountered: