我可以像 git 那样跳过 mercurial 预提交挂钩吗?
Can I skip mercurial pre-commit hooks like in git?
我想做类似 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.
(强调我的)。虽然这是指 "system-wide hooks",但它也适用于存储库中的挂钩:
$ 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
显然我的预提交挂钩正在运行。现在打败它:
$ hg --config hooks.pre-commit= commit
nothing changed
(没有什么要提交;覆盖预提交挂钩有效)。
当然,您需要知道要覆盖哪些特定挂钩,因为可能有多个预提交挂钩。
我想做类似 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.
(强调我的)。虽然这是指 "system-wide hooks",但它也适用于存储库中的挂钩:
$ 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
显然我的预提交挂钩正在运行。现在打败它:
$ hg --config hooks.pre-commit= commit
nothing changed
(没有什么要提交;覆盖预提交挂钩有效)。
当然,您需要知道要覆盖哪些特定挂钩,因为可能有多个预提交挂钩。