captainhook
captainhook copied to clipboard
Windows/WSL support
Issue / Use Case
Some developers in our company are using WSL but are using git from a windows context (e.g. by using git ui clients like SourceTree, TortoiseGit or from within an IDE like PHPStorm).
They usually have PHP installed inside WSL but not in windows.
Altough the plain git-hook-scripts are able to run, the execution of captainhook does not work.
Error messages like the following are shown when they are trying to commit:
/usr/bin/env: 'php': No such file or directory
Proposed Solution
Add an additional run-mode (like docker or local) called wsl which executes the hook in wsl context.
The existing run-exec exec setting could be used to further customize the wsl command (specify distributions etc.) used for the context switch.
Thinking of it, probably the docker run mode can be abused to execute the hooks in wsl (via the run-exec setting).
I did not look at the code yet, but if the docker run mode is not too specific towards docker in particular, the run mode could be generalized/renamed?
Thanks for the suggestion and sorry that it took a while, this somehow slipped under my radar.
I will look into the run mode thing and do some testing with WSL and the Cap'n
This could be fixed quite similarly to what you are doing with docker, I think.
To run a command in a WSL container, the command to execute would be: wsl.exe /home/myuser/project/vendor/bin/captainhook
Ideally, a user could also configure the distribution (which WSL instance to run the command in). For this, you need to supply the -d flag to wsl.exe.