svn的一个hooks,有过滤特定后缀名,指定文件大小及必须填写注解三个功能

在redhat el5.0+svn1.5.6平台测试没有问题.

      #!/bin/sh
      REPOS="$1"
      TXN="$2"
      RES="OK"
      #此处更改大小限制,这里是10M
      MAX_SIZE=10240000
      #此处增加限制文件后缀名
      FILTER='\.(zip|rar|o|obj|tar|gz)$'

      # Make sure that the log message contains some text.
      #SVNLOOK=/usr/bin/svnlook
      SVNLOOK=/opt/CollabNet_Subversion/bin/svnlook

      $SVNLOOK log -t "$TXN" "$REPOS" | egrep  "[^[:space:]]+" >/dev/null ||
      unset RES
      if [ "$RES" != "OK" ]
      then
      echo "You must input some comments for you commit" >&2
      exit 1
      fi

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

      for f in $files
      do
      #check file type
      if echo $f|tr A-Z a-z|grep -Eq $FILTER
      then
      echo "File $f is not allow ($FILTER) 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
      done

      # All checks passed, so allow the commit.
      exit 0

你可能感兴趣的:(c,SVN,redhat,F#,subversion)