我需要检查是否有任何字符串“添加/更改/修复/删除”在提交日志消息中。我正在编写一个 svn 预提交挂钩,并且预期的提交注释应该在消息中包含这 4 个字符串之一。
我正在使用的代码如下
REPOS=$1
TXN=$2
SVN="/usr/bin/svn";
SVNLOOK="/usr/bin/svnlook";
$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"
会给我用户输入的提交信息。现在我必须检查消息中是否存在任何字符串“Added、Changed、Fixed、Deleted”。那是,
if (any of the above 4 strings are not present),
exit 1
我试过了
$($SVNLOOK log -t "$TXN" "$REPOS" | grep -q "Added\|Changed\|Fixed\|Deleted"|)
但它似乎没有工作。