-
-
Notifications
You must be signed in to change notification settings - Fork 925
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
Use bash to open extensionless hooks on windows #1399
Conversation
Fix gitpython-developers#971. Partly resolve gitpython-developers#703. If the hook doesn't have a file extension, then Windows won't know how to run it and you'll get "[WinError 193] %1 is not a valid Win32 application". It's very likely that it's a shell script of some kind, so use bash.exe (commonly installed via Windows Subsystem for Linux). We don't want to run all hooks with bash because they could be .bat files. Update tests to get several hook ones working. More work necessary to get commit-msg hook working. The hook writes to the wrong file because it's not using forward slashes in the path: C:\Users\idbrii\AppData\Local\Temp\bare_test_commit_msg_hook_successy5fo00du\CUsersidbriiAppDataLocalTempbare_test_commit_msg_hook_successy5fo00duCOMMIT_EDITMSG
Thanks a lot for the contribution, much appreciated. Doing this makes a lot of sense and will generally make life easier on windows. If there is any demand, one could imagine making the default interpreter/runner binary configurable, and using |
I wrote a test for a python hook to prove to myself it would fail:
And I was thinking instead of calling bash.exe with the hook, we could call it with a call_from_unix script like this so bash will figure out the right program to use:
And use:
I'm currently not sure if this is a good idea or terrible idea. |
Sorry, actually I forgot to merge yesterday and didn't mean to instill doubt. I'd say this PR is already an improvement due to the added chance for success. If there are any issues that the new suggestions with the 'proxy script' (for lack of a better name) would solve that can be implemented, too, but I'd wait. The current solution won't add another program invocation which might be unnecessary, but always costly. |
Fix #971. Partly resolve #703.
If the hook doesn't have a file extension, then Windows won't know how
to run it and you'll get "[WinError 193] %1 is not a valid Win32
application". It's very likely that it's a shell script of some kind, so
use bash.exe (commonly installed via Windows Subsystem for Linux). We
don't want to run all hooks with bash because they could be .bat files.
test_index.py passes (two are skipped).