commitizen / cz-cli

The commitizen command line utility. #BlackLivesMatter
http://commitizen.github.io/cz-cli/
MIT License
16.6k stars 552 forks source link

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

Open AlexanderOpran opened 4 years ago

AlexanderOpran commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

@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 commented 4 years ago

@s14k51 for commits

swapnil0545 commented 4 years ago

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

danilorb commented 4 years ago

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

bespokebob commented 4 years ago

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

tiagofilipe3 commented 3 years ago

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

Didn't work for me unfortunally :(

OPthyago commented 3 years ago

Same problem...

TangJian-Eddie commented 3 years ago

same problem

moisesf10 commented 3 years ago

nothing?

IgorThierry commented 2 years ago

same problem

HermesMartins commented 2 years ago

nothing? =/

fasterinnerlooper commented 2 years ago

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 commented 1 year ago

same problem :/

mariopaglia commented 1 year ago

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 commented 5 months ago

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 commented 5 months ago

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

grumd commented 5 months ago

@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.