gitui-org / gitui-org/gitui

pre-commit hook is run at the wrong time

Open
#1,711 4 comments 1 reaction 0 assignees View on GitHub
bug good first issue help wanted
Dominant language
Rust
Stars
22.5k
Forks
773
PR merge metrics
No merged PRs in 30d

Description

Working on prepare-commit-msg hook (still).

prepare-commit-msg needs to run before commit message dialog is shown, this is doable . But in working on where to place that hook I find that the pre-commit hook is run at the wrong time. It should be run before the user gets to type in the commit message. This is how git cli runs it. It is annoying to type in a commit message for a commit that pre-commit is going to reject anyway

This is not easy to fix though. The way the user gets to choose to skip the validation by the 2 hooks that are allowed to veto a commit is by entering ^f in the commit dialog. Thats too late to bypass the pre-commit check if its run before the UI is shown

solutions
- dont worry about it. This would run the hooks out of order, prepare-message (which must run before the UI is shown), pre-commit, commit-msg and post-commit. And not mind about the mild user annoyance. There is also the slight possibility that running them out of the specified order creates a problem (if one depends on the other, say)
- change the mechanism for turning off validate. Maybe a different commit key (upper case C?) or maybe ^f toggle before the 'c' instead of after. This would be a breaking UI change though

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.