【发布时间】:2020-09-23 10:15:02
【问题描述】:
我编写了一个 commit-msg 挂钩来检查提交消息以使用正确的格式。 使用 git bash 时,它按预期工作:
$ git commit -m "test"
[Invalid Commit Message]
------------------------
Commit message needs to start with an uppercase character and be imperative
Example: Add new character model
Regex: ^[A-Z](?!\w*ed).*$
Actual commit message: "test"
Actual length: 5
当使用 Git GUI(testet with Tortoise Git 和 GitHub for Desktop)时,尽管它接受完全相同的提交消息。它似乎只是忽略了钩子。
Git GUI 不执行这个钩子吗?
更新:我发现这个钩子是由乌龟 git 执行的,它只是因为使用的字符集而出错:“”grep:-P 只支持单字节和 UTF-8 语言环境
我可以用“LC_ALL=en_US.utf8”解决这个问题(见here)
Tortoise Git 现在会阻止损坏的提交消息,但 Github Desktop 似乎仍然忽略了这个钩子。 不像乌龟,虽然我看不到它在内部做什么。
【问题讨论】:
-
看起来它正在执行,但 GUI 的字符集导致提交挂钩脚本中出现错误:“grep: -P 仅支持单字节和 UTF-8 语言环境”幸运的是,乌龟输出了日志跨度>
标签: git githooks tortoisegit github-desktop