NeogitOrg / neogit

An interactive and powerful Git interface for Neovim, inspired by Magit
MIT License
3.86k stars 227 forks source link

Compose commit messages while pre-commit hooks are running #1178

Open jamesbvaughan opened 7 months ago

jamesbvaughan commented 7 months ago

Is your feature request related to a problem? Please describe. I work in a repo with relatively slow pre-commit hooks. I'd like to be able to start composing my commit messages while the pre-commit hooks are running.

Describe the solution you'd like The most ideal behavior for my use-case would be to have the commit message editor open up as soon as you begin a commit and the pre-commit hooks start. If the hook fails, then the next time I open up the commit message editor, it would be pre-populated with a saved copy of my earlier draft.

Describe alternatives you've considered Right now my alternative is to use the current behavior and wait for the pre-commit hook to finish before composing my commit message, or to use git commit -m "some message" outside of NeoGit.


Thank you for your work on this plugin - it's a joy to use!

CKolkey commented 7 months ago

So, this is a great idea, but I don't think its possible with the current way the whole commit message flow works. We basically just hijack git opening $EDITOR by providing some RPC server for it to talk to. But, we're bound by gits semantics here, which means first the hooks run 🤷‍♂️

If you're curious, you can check out client.lua to see the rpc stuff

jamesbvaughan commented 7 months ago

So, this is a great idea, but I don't think its possible with the current way the whole commit message flow works. We basically just hijack git opening $EDITOR by providing some RPC server for it to talk to. But, we're bound by gits semantics here, which means first the hooks run 🤷‍♂️

Ah that makes sense - thanks for the quick response.

I suppose one alternative would be to have a config option that lets you compose the commit message before executing git commit at all, probably making use of a temporary file and something like git commit --file /tmp/neogit-commit-message.

I think I'd make use of an option like that if it were available. It wouldn't actually make the whole commit process take any less time, but it might feel a bit more snappy.

CKolkey commented 7 months ago

That might work for a normal commit, but for an amend we need to load the previous commit message.. There's just a lot of added complexity here to mask over the real issue - slow hooks. I'd be open to see a POC, but I don't think this is something I'm going to investigate in the foreseeable future.

jamesbvaughan commented 7 months ago

That's understandable - if I'm feeling really motivated to at some point, I might come back here with a POC.