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

Lefthook swallows STDERR for prepare-commit-msg #344

Closed
marques-work opened this issue Oct 29, 2022 · 7 comments · Fixed by #346
Closed

Lefthook swallows STDERR for prepare-commit-msg #344

marques-work opened this issue Oct 29, 2022 · 7 comments · Fixed by #346

Comments

@marques-work
Copy link

I have a prepare-commit-msg script that prints to STDERR and exits with a failure code when certain conditions are not met. However, lefthook refuses to display any output, and instead only propagates the exit code, but all output (STDERR or STDOUT) are silenced. I do not have any skip_output configured or LEFTHOOK_QUIET set.

How can I get errors from the script to print to the console?

@mrexox
Copy link
Member

mrexox commented Oct 31, 2022

Hey! Yes, there is a "hack" - lefthook uses prepare-commit-msg hook to synchronize the git hooks with hooks in a config. The output is disabled by default just not to disturb users on every commit.

To enable output anyway I can add a special ENV handling, like LEFTHOOK_VERBOSE=true which will enable all output without suppressing. WDYT about it? Would it solve the problem?

@marques-work
Copy link
Author

Hi @mrexox, yes that sounds like it might. Let me give it a try and I'll let you know if this works well. Thanks for the quick reply!

@marques-work
Copy link
Author

marques-work commented Nov 1, 2022

@mrexox hmm, setting LEFTHOOK_VERBOSE=true doesn't seem to change anything.

In my lefthook.yml, I have the following config:

prepare-commit-msg:
  scripts:
    "git-pair-commit-message.sh":
      runner: bash

And, in .lefthook/prepare-commit-msg/git-pair-commit-message.sh, I am echoing messages to both STDOUT and STDERR. Neither message is outputted to the console, though.

The way I am setting the environment variable is like so:

LEFTHOOK_VERBOSE=true git commit

Is this the correct way to do so? I have also tried export LEFTHOOK_VERBOSE=true and this also does not work.

@mrexox
Copy link
Member

mrexox commented Nov 1, 2022

Hey! This feature is not implemented yet :) But I am on my way to release it with 1.1.4 today!

@marques-work
Copy link
Author

Oh sorry, I misunderstood. But that's fast! Thanks!

@mrexox
Copy link
Member

mrexox commented Nov 1, 2022

Please, tell if that works for you! Lefthook v1.1.4 is now available with LEFTHOOK_VERBOSE env support 🙂

@marques-work
Copy link
Author

yes, it works! thank you :)

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

Successfully merging a pull request may close this issue.

2 participants