cz-cli icon indicating copy to clipboard operation
cz-cli copied to clipboard

Windows Issues from husky hooks / or just regular git hooks

Open AlexanderOpran opened this issue 5 years ago • 19 comments

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!

AlexanderOpran avatar Feb 26 '20 01:02 AlexanderOpran

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.

batyshkaLenin avatar Mar 15 '20 20:03 batyshkaLenin

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

s14k51 avatar Apr 15 '20 03:04 s14k51

@s14k51 for commits

batyshkaLenin avatar Apr 15 '20 03:04 batyshkaLenin

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

swapnil0545 avatar Apr 27 '20 06:04 swapnil0545

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

danilorb avatar May 21 '20 18:05 danilorb

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

bespokebob avatar Jun 01 '20 18:06 bespokebob

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

Didn't work for me unfortunally :(

tiagofilipe3 avatar Sep 09 '20 20:09 tiagofilipe3

Same problem...

OPthyago avatar Nov 11 '20 15:11 OPthyago

same problem

TangJian-Eddie avatar Dec 14 '20 04:12 TangJian-Eddie

nothing?

moisesf10 avatar Apr 11 '21 17:04 moisesf10

same problem

IgorThierry avatar Feb 04 '22 12:02 IgorThierry

nothing? =/

HermesMartins avatar Feb 22 '22 21:02 HermesMartins

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.

fasterinnerlooper avatar May 06 '22 12:05 fasterinnerlooper

same problem :/

pauloreis7 avatar Aug 05 '22 14:08 pauloreis7

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.

mariopaglia avatar Feb 10 '23 03:02 mariopaglia

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

grumd avatar Jan 31 '24 16:01 grumd

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

Krasava872 avatar Feb 02 '24 12:02 Krasava872

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

grumd avatar Feb 05 '24 11:02 grumd