一、提交时邮件通知
1、找到svn自带的mailer.py的位置,复制到/usr/local/bin/下
updatedb && locate mailer.py
cp /usr/share/doc/subversion-1.6.11/tools/hook-scripts/mailer/mailer.py /usr/local/bin/
2、进入svn的hooks目录,增加post-commit文件,内容如下:
#!/bin/sh
-
-
REPOS="$1"
-
REV="$2"
-
-
/usr/local/bin/mailer.py commit "$REPOS" "$REV" /home/svn/design/conf/mailer.conf
3、在/home/svn/design/conf下增加mailer.conf,内容如下:
-
[general]
-
smtp_hostname = smtp.exmail.qq.com
-
smtp_username = svn@***.com
-
smtp_password = *******
-
-
[defaults]
-
diff = /usr/bin/diff -u -L %(label_from)s -L %(label_to)s %(from)s %(to)s
-
commit_subject_prefix = [svn commit]
-
propchange_subject_prefix = [svn propchange]
-
lock_subject_prefix = [svn lock]
-
unlock_subject_prefix = [svn unlock]
-
from_addr = svn@@***.com
-
to_addr = svn@@***.com
-
generate_diffs = none
-
show_nonmatching_paths = no
-
-
[app_group]
-
for_paths = app设计文档/.*
-
to_addr = user_a@***.com user_b@***.com user_c@***.com
-
-
[pc_group]
-
for_paths = pc设计文档/.*
-
to_addr = user_a@***.com user_d@***.com user_e@***.com
网上的例子,大多对mail.conf只做了默认配置,浪费了mailer.py的功能。
不同目录的变动发送给不同人员的例子:
-
[general]
-
smtp_hostname = smtp.exmail.qq.com
-
smtp_username = xxx@xxx.com
-
smtp_password = xxxxxx
-
-
[defaults]
-
diff = /usr/bin/diff -u -L %(label_from)s -L %(label_to)s %(from)s %(to)s
-
commit_subject_prefix = [svn commit]
-
propchange_subject_prefix = [svn propchange]
-
lock_subject_prefix = [svn lock]
-
unlock_subject_prefix = [svn unlock]
-
from_addr = xxx@xxx.com
-
to_addr = xxx@xxx.com
-
generate_diffs = none #不生成差异详情(太丑)
-
show_nonmatching_paths = no #不显示未匹配的修改
-
-
[a_group]
-
for_paths = DirA/.*
-
to_addr = user1@xxx.com user2@xxx.com #a组成员邮箱列表(以空格分隔)
-
-
[b_group]
-
for_paths = DirB/.*
-
to_addr = user3@xxx.com user4@xxx.com #b组成员邮箱列表(以空格分隔)
具体的要参考mailer.conf.example(安装了subversion就会有,用updatedb && locate mailer.conf.example找下)
二、不允许日志为空
进入svn库的hooks目录,增加文件pre-commit并赋予755权限,文件内容如下:
-
#!/bin/bash
-
# Make sure that the log message contains some text.
-
-
REPOS="$1"
-
TXN="$2"
-
-
SVNLOOK=/usr/bin/svnlook
-
LOGMSG=`$SVNLOOK log -t $TXN $REPOS | wc -m`
-
-
if [ "$LOGMSG" -lt 10 ]
-
then
-
echo "please input valid messages.">&2
-
exit 1
-
fi
-
-
exit 0
参考:
http://blog.51yip.com/linux/1263.html
阅读(3128) | 评论(0) | 转发(0) |