而不是使用链式更新挂钩,我会推荐使用VREFS,与Gitolite V3一起提供。 你可以看到所有的its arguments here。
由于VREF基本上是像钩,你可以像在this script,获取该日志的消息每个git log --format=%s -1 $commit
承诺:脚本执行上git的承诺消息的政策
例:
#!/bin/bash
refname="$1"
oldrev="$2"
newrev="$3"
result=0
# Make sure we handle the situation when the branch does not exist yet
if ! [ "$oldrev" = "0000000000000000000000000000000000000000" ] ; then
excludes=(^$oldrev)
else
excludes=($(git for-each-ref --format '^%(refname:short)' refs/heads/))
fi
# Get the list of incomming commits
commits=`git rev-list $newrev "${excludes[@]}"`
# For every commit in the list
for commit in $commits
do
# check the log message for ticket number
message=`git log --format=%s -1 $commit`
ticket=`echo "$message" | grep -o "^[A-Z]\{2,3\}-[0-9]\+"`
if [ "$ticket" = "" ] ; then
echo "Commit $commit does not start with a ticket number"
result=1
fi
done
exit $result
cwhsu提到的评论:
可否请您详细说明您的第二个问题? – ziu