SVN必须添加注释才可以提交

1.cd /opt/svn/test //test为代码仓库
2.mv /opt/svn/test/hooks/pre-commit.tmpl pre-commit.tmpl //将pre-commit.tmpl重命名为pre-commit
3.vim pre-commit
  REPOS="$1"  
  TXN="$2"  
  
# Make sure that the log message contains some text.  
SVNLOOK=/opt/subversion/bin/svnlook  
$SVNLOOK log -t "$TXN" "$REPOS" | \  
 grep "[a-zA-Z0-9]" > /dev/null || exit 1  
  
# Exit on all errors.  
set -e  
  
# Check that the author of this commit has the rights to perform  
# the commit on the files and directories being modified.  
"$REPOS"/hooks/commit-access-control.pl "$REPOS" $TXN \  
 "$REPOS"/hooks/commit-access-control.cfg  
  
# All checks passed, so allow the commit.  
exit 0  
上面这个是修改前的,下面是修改后的
REPOS="$1"  
TXN="$2"  
  
# Make sure that the log message contains some text.  
SVNLOOK=/opt/subversion/bin/svnlook  
  
LOGMSG=`$SVNLOOK log -t $TXN $REPOS | wc -m`       //定义个变量,注意这里不是单引号  
  
#$SVNLOOK log -t "$TXN" "$REPOS" | \               //把这一行和下面的一行注释掉  
# grep "[a-zA-Z0-9]" > /dev/null || exit 1  
  
echo $LOGMSG > /opt/svn/aaa.txt     //为了测试变量用的,查看$LOGMSG有没有值,最后要注释掉  
if [ "$LOGMSG" -lt 5 ]    //不能少于5个字符                         
then  
 echo "\nEmpty log message not allowed. Commit aborted!" " 1>&2      exit 1  
fi  
  
# Exit on all errors.  
#set -e  
  
# Check that the author of this commit has the rights to perform  
# the commit on the files and directories being modified.  
#commit-access-control.pl "$REPOS" "$TXN" commit-access-control.cfg || exit 1   //把这一行注释掉。  
# All checks passed, so allow the commit.  
exit 0  
4.保存pre-commit文件,加可执行权限chmod +x pre-commit
5.错误解决:
  svnlook:Expected FS format '2';found format'4'
  解决方法:
  检查pre-commit脚本中,命令SVNLOOK指定的目录是否是在/subversion/bin/ 下面.

你可能感兴趣的:(SVN,强制修改注释)