2012年9月4日星期二

关于svn强制提交注释的.8的hook阅读


[原文]
# If you're having unexpected problems with a hook program, the
# culprit may be unusual (or missing) environment variables.
#
# Here is an example hook script, for a Unix /bin/sh interpreter.
# For more examples and pre-written hooks, see those in
# the Subversion repository at
# http://svn.apache.org/repos/asf/subversion/trunk/tools/hook-scripts/ and
# http://svn.apache.org/repos/asf/subversion/trunk/contrib/hook-scripts/

REPOS="$1"
TXN="$2"
SVNLOOK=/usr/bin/svnlook
STR=`$SVNLOOK log -t "$TXN" "$REPOS" | grep "[a-zA-Z0-9]"`
num1=`echo $STR |grep ^CRM | wc -c`
if [ "$num1" -eq 0  ];
then
        echo -e "\n Commit message must input JIRA No.!  " 1>&2
exit 1
fi
LOGMSG=`$SVNLOOK log -t "$TXN" "$REPOS" | grep "[a-zA-Z0-9]" | wc -c`
echo -e $LOGMESG
if [ "$LOGMSG" -lt 60 ];
then
  echo -e "\n Commit message must input message more than 30 chars!.  " 1>&2
  exit 1
fi

///////////////////////////////////////////////////////////////////////////////


1.wc -c
man wc
--------------------------------------------------------------------------
NAME
       wc - print the number of newlines, words, and bytes in files

DESCRIPTION
       Print  newline, word, and byte counts for each FILE, and a total line if more than one FILE is specified.  With no FILE,
       or when FILE is -, read standard input.

       -c, --bytes
              print the byte counts [popexizhi:字符个数]

       -m, --chars
              print the character counts

       -l, --lines
              print the newline counts[popexizhi:这个和L让自己很晕,这两个的区别到底是什么ll |wc -l 和 ll -L 的使用让自己很郁闷,不明所以啊!]

       -L, --max-line-length
              print the length of the longest line

       -w, --words
              print the word counts

       --help display this help and exit

       --version
              output version information and exit
-------------------------------------------------------------
[?] 关于-l 和-L的区别是什么?test use :ll|wc -l or ll|wc -L
2. grep ^DOC 嘻嘻,开始以为是^DOC 是什么标准的定义转义符呢,现在发现不是的,^是首字母定位符没有变,DOC是project name的:)

3.svnlook介绍[来源:http://www.subversion.org.cn/svnbook/1.1/svn-ch-5-sect-3.html]
svnlook是Subversion提供的用来查看版本库中不同的修订版本和事务

4.pre-commit文件[来源:http://blog.csdn.net/adparking/article/details/6431882]
保存后,我们要给pre-commit这个文件,加可执行权限chmod +x pre-commit,有一点在说一下就是$SVNLOOK 前面的不是单引号,具体shell语法,请参考shell手册

没有评论:

发表评论