文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>subversion邮件报告

subversion邮件报告

时间:2010-03-14  来源:sophia_wang99

Subversion邮件报告
安装环境: CentOS 5.1 + subversion-1.4.4 + httpd-2.2.8

Subversion + httpd的安装就不多说了,google一堆.我这里完全yum 安装

这里主要说一下邮件报告的问题:
svn主目录为: /var/www/svn/stuff
相关脚本:/usr/share/doc/subversion-1.4.4/tools/hook-scripts
/var/www/svn/stuff/hooks/

post-commit: 在 transaction 完成而 commit 結束,建立了新的 revision 之后执行,常用来发送邮件,我们就选他了:)
1.打开post-commit
# cd /var/www/svn/stuff/hooks/
# cp post-commit.tmpl post-commit
# chmod a+x post-commit

2.准备邮件脚本
 # cp /usr/share/doc/subversion-1.4.4/tools/hook-scripts/mailer/mailer.conf.example /var/www/svn/stuff/conf/mailer.conf
 # chown apache:apache mailer.conf
 # cp /usr/share/doc/subversion-1.4.4/tools/hook-scripts/mailer/mailer.py /var/www/svn/stuff/hooks/
 # chmod a+x mailer.py
对于mailer.py的参数说明,执行一下该脚本就有详细的说明:

[root@smtp mailer]# python mailer.py
USAGE: mailer.py commit      REPOS REVISION [CONFIG-FILE]
       mailer.py propchange  REPOS REVISION AUTHOR REVPROPNAME [CONFIG-FILE]
       mailer.py propchange2 REPOS REVISION AUTHOR REVPROPNAME ACTION [CONFIG-FILE]
       mailer.py lock        REPOS AUTHOR [CONFIG-FILE]
       mailer.py unlock      REPOS AUTHOR [CONFIG-FILE]

If no CONFIG-FILE is provided, the script will first search for a mailer.conf
file in REPOS/conf/.  Failing that, it will search the directory in which
the script itself resides.

ACTION was added as a fifth argument to the post-revprop-change hook
in Subversion 1.2.0.  Its value is one of 'A', 'M' or 'D' to indicate
if the property was added, modified or deleted, respectively.

3.案例
3.1 /var/www/svn/stuff/conf/mailer.conf

[general]
diff = /usr/bin/diff -u -L %(label_from)s -L %(label_to)s %(from)s %(to)s
mail_command = /usr/sbin/sendmail
smtp_hostname = mail.atyu30.com
smtp_username = atyu30
smtp_password = atyu30password
[defaults]
commit_subject_prefix = [repocommit]
propchange_subject_prefix = [repopropchange]
from_addr =
to_addr = [email protected]
reply_to =
generate_diffs = add copy modify
suppress_deletes = yes

这里采用公网上的邮件服务器帐号发送邮件,其中[email protected]可以是一个邮件组(发给多个用户),如果不指定 from_addr ,From: 会自动填入 committer 的使用者名称。

3.2 /var/www/svn/stuff/hooks/post-commit
#!/bin/sh
REPOS="$1"
REV="$2"

/var/www/svn/stuff/hooks/mailer.py commit "$REPOS" "$REV"
#log-commit.py --repository "$REPOS" --revision "$REV"

3.3 /var/www/svn/stuff/hooks/mailer.py
这个文件是直接拷贝过来的不用修改


这里需要注意脚本的可执行权限,及其属主,没有特别说明的文件就不用管了,我这里测试是发送成功了,祝你好运!有问题密我:)

至于相关说明我就不误导你们了,请多看手册
相关阅读 更多 +
排行榜 更多 +
弓箭手战士酷跑

弓箭手战士酷跑

飞行射击 下载
三角洲行动全面战场攀升A点进攻指南

三角洲行动全面战场攀升A点进攻指南

飞行射击 下载
僵尸射手世界大战

僵尸射手世界大战

飞行射击 下载