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

Windows/WSL support #156

Open
juckerf opened this issue Nov 24, 2021 · 3 comments
Open

Windows/WSL support #156

juckerf opened this issue Nov 24, 2021 · 3 comments

Comments

@juckerf
Copy link

juckerf commented Nov 24, 2021

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.

@juckerf
Copy link
Author

juckerf commented Nov 24, 2021

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?

@sebastianfeldmann sebastianfeldmann self-assigned this Dec 5, 2021
@sebastianfeldmann
Copy link
Collaborator

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

@shochdoerfer
Copy link
Contributor

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.

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

No branches or pull requests

3 participants