gitui-org/gitui

pre-commit hook is run at the wrong time

Open

#1,711 建立於 2023年6月1日

在 GitHub 查看
 (4 留言) (1 反應) (0 負責人)Rust (21,937 star) (721 fork)batch import
buggood first issuehelp wanted

描述

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

貢獻者指南