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

prepre-commit-msg git hook breaks IDE #634

Closed
eladchen opened this issue Jun 12, 2019 · 5 comments
Closed

prepre-commit-msg git hook breaks IDE #634

eladchen opened this issue Jun 12, 2019 · 5 comments

Comments

@eladchen
Copy link
Contributor

eladchen commented Jun 12, 2019

Hi,

While integrating this tool I noticed that my IDE started to misbehave when it performed git operations.

The example in the docs offers the following approach, which assumes /dev/tty is always available:

exec < /dev/tty && git cz --hook # <-- This fails when "not a tty"

The below uses a short-circuit to exit with an exit code of 0 in case tty is not available.

exec < /dev/tty && git cz --hook || true

Using the above solved a case where my IDE got killed during a rebase
But I suspect that anything that interacts with git is susceptible to this pitfall.

Let me know if you agree, and i'll work on a PR.

P.S:

Found a case in point:
https://stackoverflow.com/questions/55815650/lint-staged-commitizen-configuration-suitable-for-command-line-and-intellij/56555664#56555664

@jimthedev
Copy link
Member

A PR would make my day. <3

@eladchen
Copy link
Contributor Author

eladchen commented Jul 21, 2019

@jimthedev I'll get to it later tonight.

@eliraneliassy
Copy link

@eladchen - Thanks, just ran to the same issue!

@eladchen
Copy link
Contributor Author

PR submitted. Sorry for the delay, have been busier than usual.

jimthedev pushed a commit that referenced this issue Aug 14, 2019
The prepare-commit-msg git hook examples (bash & husky) assume /dev/tty is always true
This change fails silently in case /dev/tty is false.

See #634
@micalevisk
Copy link

I'm still getting this error with Visual Studio Code in my Ubuntu 😕

This is what I'm using to fix that instead of just exec < /dev/tty && git cz --hook --hook || true:

( exec < /dev/tty && git cz --hook --hook ) || true 2> /dev/null

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

No branches or pull requests

4 participants