[root@svnserver hooks]# cat pre-commit #!/bin/sh# repot && transaction argumentsREPOS="$1"TXN="$2"# svnlook commandSVNLOOK=/usr/bin/svnlook# file filter: we only allow commit .c && .h filesFILTER='.(c|h)$'# max file size in bytes after commit.MAX_SIZE=5242880# max change per one commitMAX_CHANGE_LINES=50files=$($SVNLOOK changed -t $TXN $REPOS | awk '{print $2}')# check for f in $filesdo # check file type if echo $f|grep -Eq $FILTER;then # valid file : else echo "File $f is not a .h or .c file" >&2 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)" >&2 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)" >&2 exit 1 fidoneexit 0