而不是使用鏈式更新掛鉤,我會推薦使用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