Page MenuHomePhabricator

Installed post-commit hook does not run correctly on Windows when using git bash
Closed, ResolvedPublic

Description

I'm using git-bash.exe. After installing from pypi, ran the following command on my Windows machine:

commit-message-validator install

It creates a post-commit file under the .git/hooks directory with the following content:

c:\users\a\appdata\local\programs\python\python36\python.exe c:\users\a\appdata\local\programs\python\python36\lib\site-packages\commit_message_validator\__init__.py

But in git-bash, \ is treated as escape sequence, therefore the following message is shown upon new commits:

bash: c:usersaappdatalocalprogramspythonpython36python.exe: command not found

Windows also accepts / as the path separator. I'd suggest using forward slash to make the hook compatible with git-bash.

Event Timeline

Change 404069 had a related patch set uploaded (by Dalba; owner: Dalba):
[integration/commit-message-validator@master] Use forward slash as the path separator for git hook on Windows

https://gerrit.wikimedia.org/r/404069

Change 404069 merged by jenkins-bot:
[integration/commit-message-validator@master] Use forward slash as the path separator for git hook command on Windows

https://gerrit.wikimedia.org/r/404069