linux环境下,这些脚本可以用shell php perl python去写,此次只用shell
<hook目录下,保证脚本可执行权限>
前提库名为test库
设置强制提交时注释
pre-commit
#!/bin/bash
REPOS="$1"
TXN="$2"
SVNLOOK=/usr/local/bin/svnlook
LOGMSG=`$SVNLOOK log -t "$TXN" "$REPOS" | grep "[a-zA-Z0-9]" | wc -c`
if [ "$LOGMSG" -lt 5 ];#........5.........
then
echo -e "\n为了使代码更有可读性,在您提交时必须加上至少五个字符以上的注释!" 1>&2
exit 1
fi
自动归档到网站目录钩子
post-commit
#!/bin/sh
#Description:Update the web while the svn commit!
#Author:GeekWolf
REPOS="$1"
REV="$2"
mailer.py commit "$REPOS" "$REV" /path/to/mailer.conf
export LC_CTYPE=en_US.UTF-8
/usr/local/bin/svn cleanup /var/www/html/test
/usr/local/bin/svn update /var/www/html/test --username geekwolf --password geekwolf --no-auth-cache
本文转自 geekwolf 51CTO博客,原文链接:http://blog.51cto.com/linuxgeek/995233