【问题标题】:Disabling Mercurial Hooks For Specific Repo Sources禁用特定回购源的 Mercurial Hooks
【发布时间】:2014-09-30 14:42:54
【问题描述】:

在我的计算机上,我有一些 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 签出的所有存储库都不要使用这些钩子。我该如何设置它来做到这一点?

【问题讨论】:

    标签: mercurial bitbucket mercurial-hook hgrc mercurial-extension


    【解决方案1】:

    创建一个名为 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 或者文件不包含匹配行,它将失败。

    【讨论】:

      猜你喜欢
      • 2011-03-03
      • 2010-12-14
      • 1970-01-01
      • 2011-05-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多