如果您尝试多次推送分支,我正在尝试创建一个阻止推送到远程存储库的钩子。
这是钩子:
#!/bin/bash
HG_EXE="/opt/csw/bin/hg"
CHANGESETS=`${HG_EXE} log -r $1:tip --template '{node} '`
i=0
for changeset in ${CHANGESETS}
do
BRANCH=`${HG_EXE} log -r ${changeset} --template '{branches}'`
if [ "${BRANCH}" == "" ]
then
BRANCH="default"
fi
BRANCHES[$i]=${BRANCH}
i=$i+1
done
items=${#BRANCHES[*]}
if [ $items -gt 1 ]
then
i=0
while [ "${BRANCHES[${i}+1]}" != "" ]
do
if [ "${BRANCHES[${i}]}" != "${BRANCHES[${i}+1]}" ]
then
echo "ERROR: You are trying to push more than one branch, use \"hg push -b [branch_name]\""
exit 1
fi
i=$i+1
done
fi
问题:如果我已经提交了两个分支:
changeset: 58:8d2bebe08dd9
user: keshurj <Jay.Keshur@monitisegroup.com>
date: Thu May 26 16:36:49 2011 +0100
summary: commit on default
changeset: 59:43be74e39a44
branch: branch1
tag: tip
user: keshurj <Jay.Keshur@monitisegroup.com>
date: Thu May 26 16:40:25 2011 +0100
summary: commit on branch1
并尝试使用 hg push –b branch1 推送,钩子仍然将 ${HG_NODE} 视为 8d2bebe08dd9,这是默认值。
有什么方法可以确保通过远程挂钩一次只推送一个分支?
接受任何和所有建议(回复:此工作流程:))