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

Program hangs if repo uses prepare-commit-hook that requires user input #2546

Open
jaredmcateer opened this issue Mar 4, 2025 · 6 comments · May be fixed by #2547
Open

Program hangs if repo uses prepare-commit-hook that requires user input #2546

jaredmcateer opened this issue Mar 4, 2025 · 6 comments · May be fixed by #2547
Labels
bug Something isn't working

Comments

@jaredmcateer
Copy link

Describe the bug
If a repo implements a prepare-commit-msg which requires user input gitui will hang on various operations that trigger the hook (commit, rebase, merge, cherry pick).

This is a pretty common pattern in repos using commitizen as one of the options that the project recommends is using prepare-commit-msg

To Reproduce

minimal example here: https://github.com/jaredmcateer/cz-gitui

Steps to reproduce the behavior:

  1. Open repo with prepare-commit-msg that requires user input
  2. Add/Modify a file
  3. Stage file
  4. Go to 'staged change' in gitui
  5. Press 'c'
  6. Observe gitui is unresponsive

Screenshots

In your processes you will see something like this:
Image

Context (please complete the following information):

  • OS/Distro + Version: tested on Mac OS Sonoma 14.7.1 & Pop_OS! 22.0.4 LTS
  • GitUI Version: gitui nightly 2025-03-04 ()
  • Rust version: rustc 1.82.0 (f6e511eec 2024-10-15)

Additional context
Lazygit also suffers from this, and the current workaround is to override all the commit-like commands with custom keybindings to disable Husky, but that will also kill other useful things like pre-commit hooks that run tests/linters.

@jaredmcateer jaredmcateer added the bug Something isn't working label Mar 4, 2025
@DaRacci
Copy link

DaRacci commented Mar 5, 2025

this sounds like a near impossible issue to fix, the easy solution might be adding a timeout to the command invocation.

@extrawurst
Copy link
Collaborator

@DaRacci i agree that is what we should do here. interested in giving this a go?

@DaRacci DaRacci linked a pull request Mar 5, 2025 that will close this issue
4 tasks
@jaredmcateer
Copy link
Author

FWIW I found lazygit allows committing via the system editor with shift+c which does allow gracefully handling the hook, but they have no functionality for the other commands that trigger the prepare-commit-msg hook and cause it to hang as well. You can also build custom menu/commands that run in a subprocess that other users are reporting works for them but I haven't dug into that.

I understand if this is too much work. I tend to agree with the sentiment that what commitizen is doing is going against the spirit of git hooks. I just happen to work on a lot of repos that aren't mine with it and having my TUI frozen trying to do something like a rebase drives me a bit batty, so at least having a timeout is better than having to kill the process and reset my terminal.

@DaRacci
Copy link

DaRacci commented Mar 13, 2025

FWIW I found lazygit allows committing via the system editor with shift+c which does allow gracefully handling the hook, but they have no functionality for the other commands that trigger the prepare-commit-msg hook and cause it to hang as well. You can also build custom menu/commands that run in a subprocess that other users are reporting works for them but I haven't dug into that.

I understand if this is too much work. I tend to agree with the sentiment that what commitizen is doing is going against the spirit of git hooks. I just happen to work on a lot of repos that aren't mine with it and having my TUI frozen trying to do something like a rebase drives me a bit batty, so at least having a timeout is better than having to kill the process and reset my terminal.

how does using the system editor allow these hooks to work, i may not quite be following could you record a clip of how this functions?

@jaredmcateer
Copy link
Author

jaredmcateer commented Mar 14, 2025

Yea sure. Sorry I'm on wayland and I haven't quite figured out how to get something going that shows my key presses in screencasts but basically I stage the file, press shift+c it switches the the terminal where I can follow commitizens prompts, it then drops me into my $EDITOR (nvim) to make any additional changes and then :wq to save and commit, then I'm back in the terminal and when I press any button I'm brought back into lazygit.

lazygit.webm

@DaRacci
Copy link

DaRacci commented Mar 15, 2025

Thanks for the demo, I was hoping this would give a lead but it seems like its just dropping you into a shell where git commit has been ran.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants