#!/bin/sh REPOS="$1" TXN="$2" #此处更改大小限制,这里是5M MAX_SIZE=5242880 #此处增加限制文件后缀名 FILTER='.(zip|rar|o|obj|tar|gz)$' SVNLOOK=/usr/bin/svnlook LOGMSG=`$SVNLOOK log -t "$TXN" "$REPOS" | wc -c` if [ "$LOGMSG" -lt 9 ] then echo "请输入8个字符以上的提交说明" 1>&2 exit 1 fi files=$($SVNLOOK changed -t $TXN $REPOS |cut -d " " -f 4-) rc=0 echo "$files" | while read f; do if echo $f|tr A-Z a-z|grep -Eq $FILTER; then echo "不支持($FILTER)格式的文件" >&2 exit 1; fi filesize=$($SVNLOOK cat -t "$TXN" "$REPOS" "$f" | wc -c) if [ "$filesize" -gt "$MAX_SIZE" ] then echo "文件不允许大于5M(必须小于等于$MAX_SIZE)B" >&2 exit 1 fi done