为了方便管理,svn上传需要限制文件大小
svn有几种钩子,资料一搜一大把,限制上传文件大小需要用到 pre-commit
在仓库hooks目录下有示例配置文件,新建一个名为 pre-commit 的脚本,内容如下:

#!/bin/bash
REPOS="$1"
TXN="$2"
SVNLOOK=/usr/bin/svnlook
MAX_SIZE=512000

files=$($SVNLOOK changed -t $TXN $REPOS | awk '{print $2}')

# check check 
if [[ $files =~ "project_nuli" ]];then
for f in $files
do
    # 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
done
fi
exit 0

客户端提交大于500K文件会返回 File $f is too large (must <= $MAX_SIZE)

提交时,强制用户输入注释内容:
vim pre-commit

#!/bin/bash
REPOS="$1"
TXN="$2"
SVNLOOK=/usr/bin/svnlook
files=$($SVNLOOK changed -t $TXN $REPOS | awk '{print $2}')
for f in $files
do
    LOGMSG=`$SVNLOOK log -t "$TXN" "$REPOS" | grep "[a-zA-Z0-9]" | wc -c`
    if [ "$LOGMSG" -lt 5 ];then
        echo -e "\nLog message cann't be empty! you must input more than 5 chars as comment!." 1>&2
        exit 1
    fi
done
exit 0