2014-09-30 174 views
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