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

Include git output when commands fail #685

Open
technicalpickles opened this issue Mar 21, 2024 · 1 comment
Open

Include git output when commands fail #685

technicalpickles opened this issue Mar 21, 2024 · 1 comment
Labels
feature request A new lefthook feature description

Comments

@technicalpickles
Copy link
Contributor

⚡ Summary

Sometimes there are failures coming from git, but the output isn't shown so it is very hard to start debugging. LEFTHOOK_VERBOSE=1 can help, but I think it'd be better for users to have more context up front

Value

Lefthook git-related failures will be easier to debug. Having an more specific error will help people find/file reports

Behavior and configuration changes

Here's the current behavior:

CleanShot 2024-03-21 at 08 15 55

Here's the behavior with LEFTHOOK_VERBOSE=1:

CleanShot 2024-03-21 at 08 17 14

Not sure exactly what the output should look like, but some quick initial thoughts:

[lefthook] Couldn't restore hidden unstaged files: git had exit code 1
cmd: [git apply -v --whitespace=nowarn --recount --unidiff-zero .git/info/lefthook-unstaged.patch]
out: Checking patch lua/plugins/editor.lua...
error: while searching for:
        opts = {
        },

error: patch failed: lua/plugins/editor.lua:122
error: lua/plugins/editor.lua: patch does not apply
Checking patch lua/plugins/lsp.lua...
Checking patch lua/plugins/telescope.lua...
error: while searching for:
                function ()

error: patch failed: lua/plugins/telescope.lua:238
error: lua/plugins/telescope.lua: patch does not apply
@technicalpickles technicalpickles added the feature request A new lefthook feature description label Mar 21, 2024
@doniz
Copy link

doniz commented Mar 21, 2024

It's out of scope and I believe it's really necessary to have a context why that happened. However, I got the same issue one hour ago, how unexpectedly that happened 😄 But in my case I solved this by adding stage_fixed

Used only for pre-commit hook. Is ignored for other hooks.
When set to true lefthook will automatically call git add on files after running the command or script.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request A new lefthook feature description
Projects
None yet
Development

No branches or pull requests

2 participants