日期:2014-05-16 浏览次数:20726 次
#!/bin/sh # repot && transaction arguments REPOS="$1" TXN="$2" # svnlook command SVNLOOK=/usr/local/bin/svnlook # file filter: we only allow commit .c && .h files. FILTER='\.(c|h)$' # max file size in bytes after commit. MAX_SIZE=102400 # max change per one commit MAX_CHANGE_LINES=50 files=$($SVNLOOK changed -t $TXN $REPOS | awk '{print $2}') # check for f in $files do # check file type if echo $f | grep -Eq $FILTER ; then # valid file : else echo "File $f is not a .h or .c file" >> /dev/stderr exit 1 fi # check file size filesize=$($SVNLOOK cat -t $TXN $REPOS $f | wc -c) if [ $filesize -gt $MAX_SIZE ] ; then echo "File $f is too large (must <= $MAX_SIZE)" >> /dev/stderr exit 1 fi # check change lines changelines=$($SVNLOOK diff -t $TXN $REPOS $f | grep -E '^(\+|-)' | wc -l) if [ $changelines -gt $MAX_CHANGE_LINES ] ; then echo "File $f changes too much ($changelines lines, must <= $MAX_CHANGE_LINES)" >> /dev/stderr exit 1 fi done exit 0
------解决方案--------------------
如果使用 乌龟(Tortoise)的SVN客户端的话,在SVN目录的属性中可以设置过滤掉指定后缀的文件类型,还可以设置commit的日志长度,总之非常方便;楼主可以看下。我不记得是否支持限制commit的文件大小,应该可以的
------解决方案--------------------