Skip to content

fix: run pre-commit hook before opening commit dialog#2909

Open
ChihebBENCHEIKH1 wants to merge 1 commit intogitui-org:masterfrom
ChihebBENCHEIKH1:fix/pre-commit-hook-timing
Open

fix: run pre-commit hook before opening commit dialog#2909
ChihebBENCHEIKH1 wants to merge 1 commit intogitui-org:masterfrom
ChihebBENCHEIKH1:fix/pre-commit-hook-timing

Conversation

@ChihebBENCHEIKH1
Copy link
Copy Markdown

Closes #1711

The pre-commit hook 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:

  1. pre-commit — when dialog opens (before user types)
  2. prepare-commit-msg — when dialog opens (populates message)
  3. commit-msg — when user submits
  4. post-commit — after commit

This matches the behavior described in the Git docs and aligns with GUI clients like Fork.

Note: The verify toggle (Ctrl+F) is respected — if disabled, the pre-commit hook is skipped at open time as well.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pre-commit hook is run at the wrong time

1 participant