neogit icon indicating copy to clipboard operation
neogit copied to clipboard

Compose commit messages while pre-commit hooks are running

Open jamesbvaughan opened this issue 1 year ago • 4 comments

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!

jamesbvaughan avatar Feb 17 '24 22:02 jamesbvaughan

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

CKolkey avatar Feb 18 '24 19:02 CKolkey

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.

jamesbvaughan avatar Feb 19 '24 03:02 jamesbvaughan

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.

CKolkey avatar Feb 19 '24 08:02 CKolkey

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

jamesbvaughan avatar Feb 19 '24 17:02 jamesbvaughan