better-commits icon indicating copy to clipboard operation
better-commits copied to clipboard

Resume commit message after pre-commit hook failure.

Open damian-giebas-solidstudio opened this issue 7 months ago • 2 comments

When using better-commits with pre-commit hooks, if the commit fails due to hook failures (e.g., linting errors), the user needs to go through the entire better-commits flow again after fixing the issues and running git add -u.

Requested Feature:

  • Save the commit message in a way that allows git commit to reuse it after hook failures
  • Or provide a command like better-commits --resume to reuse the last generated message
  • Or automatically detect staged changes and ask if user wants to reuse the previous message

Use case

better-commits           # User creates message interactively  
# ❌ Pre-commit fails
# User fixes code
git add -u
git commit               # Should reuse the previous message
# OR
better-commits --resume  # Reuse last message without going through flow again

Best regards. Damian

@damian-giebas-solidstudio - Are you using "cache_last_value"=true?

With that set you can go back through the prompts fairly quickly and adjust whatever part need to be adjusted. - I mention this because many pre-commit hooks at my work cannot be fixed by git add. They lint the commit message itself. Something like --resume would be faster for your use case, so I don't mind looking into adding it. - It might take me a sec to get around to it with work, other projects, etc...

Everduin94 avatar Sep 26 '25 13:09 Everduin94

I didn't notice that there was such a thing as cache_last_value. Thank you. As for the feature itself, I've been doing without it for months, so waiting until you find the time for it won't change much. It's just a ‘nice to have’.