我期待在SVN以下格式提交信息。
描述:(改变的一些描述)
实体:(改变请求数目)
如果注释,同时承诺不遵循上述格式的错误信息应该被抛出。 这个想法是检查提交信息的钥匙串“描述”和“实体”。 我也检查了邮件中的注释的存在。
我使用下面的代码,但我没能拿到检查字符串“描述”工作。 (对空注释的检查,但工作的罚款。)你能告诉我可能是做错了什么?
REPOS=$1
TXN=$2
LOG="/home/svn/testSVN/logs/precommithook.log"
GREP=/bin/grep
ECHO=/bin/echo
SVN="/usr/bin/svn";
SVNLOOK="/usr/bin/svnlook";
#Logs the current Transaction ID
"${ECHO}" "Transcation Id ${TXN}" >> "$LOG"
$SVNLOOK log "$REPOS" -t "$TXN" | grep "[a-zA-Z0-9]" > /dev/null
GREP_STATUS=$?
if [ $GREP_STATUS -ne 0 ]
then
"${ECHO}" "No Log comments present" >> "${LOG}"
echo "Your commit has been blocked because you didn't give any log message" 1>&2
echo "Please write a log message describing the purpose of your changes and" 1>&2
echo "then try committing again. -- Thank you" 1>&2
exit 1
fi
$SVNLOOK log "$REPOS" -t "$TXN" | grep [a-zA-Z0-9] | grep -q "Description" > /dev/null
GREP_DESCRIPTION_STATUS=$?
if [ $GREP_DESCRIPTION_STATUS –ne 0 ]
then
"${ECHO}" "Description not found in the comment" >> "${LOG}"
echo "Your commit has been blocked because you didn't give the Description in your commit message" 1>&2
echo "Please write a log message describing the purpose of your changes and" 1>&2
echo "then try committing again. -- Thank you" 1>&2
exit 1
fi
exit 0
我试图用简单的grep“说明”以及grep的-w“描述”了。 仍然不可能得到它。