1

在我的计算机上,我有一些Mercurial提交挂钩在每次提交时运行,以确保我正确地分支并执行其他一些操作。但我只需要这些工作项目。针对特定回购来源禁用Mercurial钩子

以下是我的〜/ .hgrc文件中实现了钩:

[hooks] 
# This hook will warn you if you make a commit directly to trunk. 
pretxncommit.default_check=/virtualhosts/mercurial-hooks/default_check.sh 

# This hook will warn you if you branch from something other than default. 
pretxncommit.branch_check=/virtualhosts/mercurial-hooks/branch_check.sh 

对于我的个人项目,我不希望使用相同的,讨厌的钩(被设置为全局)。我希望从bitbucket签出的所有回购协议不使用这些挂钩。我如何设置它来做到这一点?

回答

3

创建一个名为from_bitbucket.sh文件,该文件包含以下内容:

#!/bin/sh 
test -f $HG_PENDING/.hg/hgrc || exit 1 
egrep -q 'default.*bitbucket\.org' $HG_PENDING/.hg/hgrc || exit 1 
exit 0 

给脚本执行权限(例如,chmod 755 from_bitbucket.sh),并将其移动到要永久保存在任何目录。

改变你的钩子一样的东西:

pretxncommit.default_check=/path/to/from_bitbucket.sh || /virtualhosts/mercurial-hooks/default_check.sh 

这将首先执行from_bitbucket.sh和早期成功中止脚本是否成功。该脚本仅检查存储库的.hg/hgrc文件中是否存在与default.*bitbucket\.org匹配的行(如果您推送到/从bitbucket中,通常应该存在于[paths]部分中)。如果没有.hg/hgrc或文件不包含匹配的行,它将失败。

+0

工作,谢谢! – pthurmond 2014-09-30 19:17:28