我想做一些类似于 git commit --no-verify 的事情,但是使用 Mercurial。有什么办法可以做到吗?
最佳答案
如 hg help config
documentation 中所述:
... Multiple hooks can be run for the same action by appending a suffix to the action. Overriding a site-wide hook can be done by changing its value or setting it to an empty string. Hooks can be prioritized by adding a prefix of "priority." to the hook name on a new line and setting the priority. The default priority is 0.
(强调我的)。虽然这指的是“系统范围的 Hook ”,但它也适用于存储库内的 Hook :
$ sed -n '/hooks/,+1p' .hg/hgrc
[hooks]
pre-commit = ./foo.sh
$ cat foo.sh
#! /bin/sh
echo foo
exit 1
$ hg commit
foo
abort: pre-commit hook exited with status 1
显然我的预提交 Hook 正在工作。现在打败它:
$ hg --config hooks.pre-commit= commit
nothing changed
(没有什么可提交的;覆盖预提交 Hook 有效)。
当然,您需要知道要覆盖哪个特定 Hook ,因为可能有多个预提交 Hook 。
关于git - 我可以像 git 一样跳过 Mercurial 预提交钩子(Hook)吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39016675/