git - 我可以像 git 一样跳过 Mercurial 预提交钩子(Hook)吗?

标签 git mercurial hook pre-commit-hook pre-commit

我想做一些类似于 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/

相关文章:

Wordpress 添加新的用户 Hook

android - 从 Github 导入 Android 项目时遇到问题

git - BUG : unpack-trees. c:699: pos 必须指向这个目录的第一个条目

git - 克隆 git 或 hg 存储库时如何节省磁盘使用量?

javascript - Hook window.location.* 分配和 window.location.assign

git - 如何在 git add 之前自动调用脚本?

git - 防止 git 要求提交更改

git - 如何截断 git log 中的字段 --pretty

Mercurial 最佳实践 - 功能/任务分支?

eclipse Mercurial插件安装错误