fix: run pre-commit hook before opening commit dialog#2909
Open
ChihebBENCHEIKH1 wants to merge 1 commit intogitui-org:masterfrom
Open
fix: run pre-commit hook before opening commit dialog#2909ChihebBENCHEIKH1 wants to merge 1 commit intogitui-org:masterfrom
ChihebBENCHEIKH1 wants to merge 1 commit intogitui-org:masterfrom
Conversation
The pre-commit hook was running after the user typed their commit message, wasting time on messages that would get rejected. Now it runs when the commit dialog opens, matching Git CLI behavior where pre-commit runs before the user types a message. The hook is extracted into a run_pre_commit_hook() helper to keep open() under the clippy::too_many_lines threshold.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1711
The
pre-commithook was running after the user typed their commit message, wasting time composing messages that would get rejected. Per Git documentation: "The pre-commit hook is run first, before you even type in a commit message."Before: User opens commit dialog → types message → submits → pre-commit rejects → message wasted
After: User opens commit dialog → pre-commit runs first → if rejected, dialog never opens
Hook execution order is now:
pre-commit— when dialog opens (before user types)prepare-commit-msg— when dialog opens (populates message)commit-msg— when user submitspost-commit— after commitThis matches the behavior described in the Git docs and aligns with GUI clients like Fork.
Note: The
verifytoggle (Ctrl+F) is respected — if disabled, the pre-commit hook is skipped at open time as well.