Skip to content

pre-commit hook is run at the wrong time #1711

Open
@pm100

Description

@pm100

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomershelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions