注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

Code@Pig Home

喜欢背着一袋Code傻笑的Pig .. 忧美.欢笑.记忆.忘却 .之. 角落

 
 
 

日志

 
 

[SVN] 自动 commit 通知 ---- mailer.conf  

2008-07-10 15:16:46|  分类: scm_svn |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |
以 FreeBSD 6.2 为例。注意,此 mailer.conf 是 svn 自己的。而 FreeBSD 也有个 mailer.conf,参见 man mailer.conf。


Quick Install
(1) 安装 swig (ports/devel/swig13)

(2) 安装 svn,在 configure 时,会自动找系统是否安装了 swig,因此 swig 要放在前面
    cd ports/devel/subversion
    make install

(3) 安装 swig-py,请阅读 ports/devel/subversion/work/subversion-1.6.2/subversion/bindings/swig/INSTALL
    cd ports/devel/subversion/work/subversion-1.6.2
    gmake swig-py
    gmake check-swig-py
    gmake install-swig-py DESTDIR=/usr/local/svn-python
    echo /usr/local/svn-python > /usr/local/lib/python2.5/site-packages/subversion.pth

(4) 假设建立好的仓库在 /home/svnrepos
    cd /home/svnrepos/hooks
    cp post-commit.tmpl post-commit
    chmod +x post-commit

    修改 post-commit 中最下面的几行命令为:
    PATH=/usr/bin:/usr/local/bin; export PATH
    /usr/local/share/subversion/hook-scripts/mailer/mailer.py commit "$REPOS" "$REV"

    cp /usr/local/share/subversion/hook-scripts/mailer/mailer.conf /home/svnrepos/conf/
    修改 /home/svnrepos/conf/mailer.conf:
      Uncomment the line
        #mail_command = /usr/sbin/sendmail
      and change the line
        to_addr = invalid@example.com
      to
        to_addr = <your e-mail address> <hobbes' e-mail address> <susie's e-mail address>


配置 mailer.conf
假设svn目录结构为:
REPOS/
    program/client/      客户端代码
    program/server/    服务端代码
    design/                   策划文档
那么我们可以配置:
[server]
for_paths = /program/server
to_addr = server programmers' email
commit_subject_prefix = [server]

[client]
for_paths = /program/client
to_addr = client programmers' email
commit_subject_prefix = [client]

[design]
for_paths = /design
to_addr = designers' email
commit_subject_prefix = [design]


FAQ
<1> Warning: 'post-commit' hook failed with error output:
Traceback (most recent call last):
  File "/usr/share/subversion/hook-scripts/mailer/mailer.py", line 1307, in ?
    sys.argv[3:3+expected_args])
  File "/var/lib/python-support/python2.4/svn/core.py", line 217, in run_app
    return apply(func, (_core.application_pool,) + args, kw)
  File "/usr/share/subversion/hook-scripts/mailer/mailer.py", line 77, in main
    messenger.generate()
  File "/usr/share/subversion/hook-scripts/mailer/mailer.py", line 369, in generate
    self.output.finish()
  File "/usr/share/subversion/hook-scripts/mailer/mailer.py", line 275, in finish
    self.pipe.tochild.close()
IOError: [Errno 32] Broken pipe
这个错误 ... 因为你没装 sendmail,嘿嘿。

<2> 都设置好了,还是没收到信。测试下:
------------------------------
import subprocess, sys
cmd  = ['/usr/sbin/sendmail', '-f', 'a@b.com', 'your_email']
pipe = subprocess.Popen(cmd, stdin=subprocess.PIPE, close_fds = True)
pipe.stdin.write(r'Subject: abc\n\ngood')
pipe.stdin.close()
pipe.wait()
------------------------------
看看是否正常工作了。还有留意发件人地址,有些邮件服务器会检查发件人是否合法的,sendmail
正常工作,但邮件服务器把你发出去的邮件丢弃了。

<3> 中文显示问题
mailer.py 中,邮件的编码,默认用了 utf-8,svn log 也用了 utf-8 编码,而假设我们项目代码的注释用了 gbk。则需要修改下 mailer.py 文件。比如统一转换为 gbk 编码:
  # 修改邮件头
  hdrs = 'From: %s\n'    \
     ...
     'Content-Type: text/plain; charset=gbk\n' \
     ...

  # 修改log编码
  mylog = repos.get_rev_prop(svn.core.SVN_PROP_REVISION_LOG) or '',
  log = (mylog[0].decode('utf-8').encode('gbk'), )
  data = _data(
    log=log,
    ...
  )


参考资料
配置 mailer.conf
http://opensource.perlig.de/svnmailer/doc-1.0/
http://www.inf.ufpr.br/renato/repository.html

配置 python module 路径
http://bob.pythonmac.org/archives/2005/02/06/using-pth-files-for-python-development/
  评论这张
 
阅读(3138)| 评论(0)
推荐 转载

历史上的今天

在LOFTER的更多文章

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017