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 Issues from husky hooks / or just regular git hooks #709

Open
AlexanderOpran opened this issue Feb 26, 2020 · 18 comments
Open

Windows Issues from husky hooks / or just regular git hooks #709

AlexanderOpran opened this issue Feb 26, 2020 · 18 comments
Labels
bug windows Windows OS

Comments

@AlexanderOpran
Copy link

AlexanderOpran commented Feb 26, 2020

Multiplication of stdout (I traced this issue down to the log-update package but I could be wrong). Seems like the package doesn't know what to cut from the output (wrong terminal height or something).

image

Colors are not showing (I can set a env variable to bypass this but the multiplication bug is still there). Again, I believe this is a windows and dependencies issue. This happens with regular git hooks created manually, not only with husky.

Thanks!

@batyshkaLenin
Copy link

I have exactly the same problem when I add to package.json:
"prepare-commit-msg": "exec < /dev/tty && git cz --hook || true"
If i use npm run commit at "commit": "git-cz", then everything breaks down. In addition to commitizen, I have a Prettier hook installed.

@s14k51
Copy link

s14k51 commented Apr 15, 2020

@AlexanderOpran @batyshkaLenin
Yeah. When used with prepare-commit-msg, it shows me that problem as well. So, I avoided using hooks with commitizen altogether. By the way for what purposes are you using commitizen+hooks (like prepare-commit-msg)? Is it for a git rebase scenario?

@batyshkaLenin
Copy link

@s14k51 for commits

@swapnil0545
Copy link

Same issue here. Waiting for a fix for this hook :(

@danilorb
Copy link

I was having the same problem.
I installed the ConEmu terminal and solved my problem.

@bespokebob
Copy link

It looks like this is a problem with the inquirer library that commitizen uses for prompting: SBoudrias/Inquirer.js#793

@tiagofilipe3
Copy link

I was having the same problem.
I installed the ConEmu terminal and solved my problem.

Didn't work for me unfortunally :(

@dmwelch dmwelch added bug windows Windows OS labels Sep 14, 2020
@OPthyago
Copy link

Same problem...

@TangJian-Eddie
Copy link

same problem

@moisesf10
Copy link

nothing?

@IgorThierry
Copy link

same problem

@HermesMartins
Copy link

nothing? =/

@fasterinnerlooper
Copy link

It looks like cz is piping the input to vim instead of passing it and waiting for the output. If things aren't set up properly and you run git cz and it opens vim, the input behaves in an unusual way.

@pauloreis7
Copy link

same problem :/

@mariopaglia
Copy link

I'm having the same issue, is there a solution for this? From what I've seen in other Issues, people have been having the same problem for years. I'm afraid to implement it in my project because if someone wants to program through Windows, they will have trouble when committing.

@grumd
Copy link

grumd commented Jan 31, 2024

Add this line at the beginning of your husky hook.

if sh -c ": >/dev/tty" >/dev/null 2>/dev/null; then exec </dev/tty >/dev/tty 2>&1; fi

Took me a few hours to came up with this solution.
Now I get full color and interactivity in Git Bash inside Windows Terminal on Win 11.
Bonus: it also improved my lint-staged prettier hook.

image image

@Krasava872
Copy link

@grumd Oh, thanks for you solution, maybe you can explain it for me? I'm bad on bash scripts.

@grumd
Copy link

grumd commented Feb 5, 2024

@Krasava872 if sh -c ": >/dev/tty" checks if /dev/tty is available, and if it is, it redirects stdin, stdout and stderr to /dev/tty.

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

No branches or pull requests