-
Notifications
You must be signed in to change notification settings - Fork 553
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
How to husky prepare-commit-msg on windows? #627
Comments
I'm having the same issue. Can someone provide an easy workaround for this ? |
Error message on windows is What is the possible workaround for Windows? |
same issue. |
I got the error on windows:
|
I developed this feature for people using bash (which works for MacOS + Linux). I'm not sure how to perform the same effect using windows. My sense is that there needs to be an additional check in the I do not use windows, and so this would be difficult for me to get working (but not impossible, added to my task list). If any of y'all figure out a workaround in the meantime, please post here and / or submit a pr to this repo. |
This thread here suggests using |
@olgn - Can we perhaps get more information around this. I've been using WSL for Windows as a workaround but realistically my whole team is running windows It would be nice to have a solution to this, |
@sadsa I'll give it a shot. As you know (because you had to follow the instructions in the README), the method of enforcement for commitizen commit messages uses Husky. Husky pre-commit hooks are tied into the corresponding The The bit of code right before the So my previous comment holds - if someone here can figure out how to replicate the behavior of Let me know if any of that could use clarification. |
Hi, I've found something that works on my windows 10, with pure batch (bat) scripts (so it does not require bash or git bash) In my package.json: {
"husky": {
"hooks": {
"prepare-commit-msg": "prepare-commit-msg",
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
}
}
} I have created two bat files at the root of my repo:
@ECHO off
SETLOCAL
CALL :find_dp0
set "_prog=%dp0%exec-git-cz.cmd"
IF NOT EXIST "%_prog%" (
ECHO "%_prog% does not exist"
ENDLOCAL
EXIT /b 1
)
start /wait call "%_prog%" --hook %*)
:find_dp0
SET dp0=%~dp0
EXIT /b
@ECHO off
SETLOCAL
CALL :find_dp0
set "_prog=%dp0%node_modules\.bin\git-cz.cmd"
IF NOT EXIST "%_prog%" (
ECHO "%_prog% does not exist, please install commitizen"
ENDLOCAL
EXIT /b 1
)
call "%_prog%" %*
ENDLOCAL
EXIT %errorlevel%
:find_dp0
SET dp0=%~dp0
EXIT /b |
@neilime interesting solution. The next obvious step would be to make one command (to place in the
that way the prepare-commit-msg command is the same for every user that installs a commitizen enforced repo, and they can all enjoy the benefits of commitizen |
@neilime, Although your trick works, I seem to be running into the following issue where the up and down arrow keys causes this very annoying duplication effect. I'm on Windows 7 Enterprise, Git version 2.24.0.windows.2 |
@shardool I'm on Windows 10 Pro (Insider Preview) - Node v13.0.1 - 2.24.0.windows.1 - and don't have any troubles The issue you're facing, is maybe due to Inquirer.js: SBoudrias/Inquirer.js#778 Try to upgrade your nodejs to fix it. |
@neilime I'm on node version v12.13.0. I tried older version too. |
@olgn What about providing the feature out of the box by cz-cli? |
Any solutions to the duplication bug (#627 (comment))? I am on the latest Windows 10 Update / NodeJS LTS version. Tried some older versions as well, same issue. |
I now have access to a windows computer to test this out and work on a solution. First observations are that this works with both WSL (as @sadsa and @nico1988 pointed out) and also that it works with Git-Bash - presumably because they are bash shells. So one way to get commitizen to work is to commit using either of those two programs... I think Git-Bash is supported on windows 7-10, and WSL is 10 only (could be wrong there). My next observation is that, although the output of my terminal looks very similar to @shardool, (eg duplicating with every keystroke), there is no error code - this command works (albeit it looks terrible). It has the same behavior in powershell and cmd. Can someone who got an error running this tell me what version of windows, what shell, and more detailed error trace? |
I've made the fix for me runnig js script-file in prepare-commit-msg phase and in this file I check user's system and trigger exec < dev/tty.... or that two files for Windows |
Hi,
got it working by doing :
|
the script was not compatible with windows see commitizen/cz-cli#627
I got this "working" on windows by adding #!/bin/sh
[[ "$(uname -a)" = *"MINGW64"* ]] && exit 0
[ -n "$CI" ] && exit 0
. "$(dirname "$0")/_/husky.sh"
exec < /dev/tty && npm run cz -- --hook || true this will just bypass that file on windows and you can still use the "select the type of change" cli interface. If you are using cygwin or some funky 32bit windows you might need to tweak it |
I'm not sure I fully understand what #!/usr/bin/env sh
case `uname` in
*CYGWIN*|*MINGW*|*MSYS*) exit 0;;
esac
. "$(dirname -- "$0")/_/husky.sh"
exec < /dev/tty && git cz --hook || true The check is for all windows terminals (cygwin, minigw and powershell/cmd) I guess husky hook is there for forcing But this removes errors at least for me, so that I can use interactive shell for commiting on windows. |
Here is a workaround that I am doing:
|
Using husky it is very useful but script which is there is designed only for bash purpose.
What could be solution for Windows?
The text was updated successfully, but these errors were encountered: