本文介绍了SVN钩子mailer.py配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试在 subversion 1.6.12 服务器上设置提交后挂钩,以便在提交时发送通知邮件.

I try to set up a post-commit hook on a subversion 1.6.12 server to send a notification mail on commit.

我已经在使用带有基本配置的脚本 mailer.py(由 subversion 团队在 utils 文件夹中提供)(只需在每次提交后发送一封电子邮件)并且运行良好.

I am already using the script mailer.py (delivered by subversion team in the utils folder) with basic configuration (just send an email after each commit) and it works well.

但现在,我只想在/tags/文件夹中有提交时发送邮件.

But now, I want to send a mail only when there is a commit in the /tags/ folder.

这是我的标准 mailer.conf(效果很好):

This is my standard mailer.conf (that works well) :

[general]
smtp_hostname = xxx.xxx.xxx.xxx

[defaults]
from_addr = [email protected]
to_addr = [email protected]

这就是我试图为仅在/tags/上的邮件配置的内容:

And this is what I tried to configure for a mail on /tags/ only :

[general]
smtp_hostname = xxx.xxx.xxx.xxx

[defaults]
from_addr = [email protected]
to_addr = [email protected]
for_paths = .*/tags/.*

但看起来我误解了配置,因为它不起作用:我收到所有提交的邮件(标签与否)

But it looks like I am misunderstand the configuration because it does not work : I receive mail on all commits (tags or not)

有什么想法吗?谢谢.

推荐答案

确实没有什么好的方法可以做到这一点.mailer.py 的设计使任何与其他组不匹配的提交都转到默认组.

There isn't really a good way to do this. mailer.py is designed so that any commit that isn't matched to another group goes to the defaults group.

mailer 中的文档.conf.example 暗示了这一点,但并没有很好地解释它:

The documentation in mailer.conf.example hints at this but doesn't really explain it very well:

在 [defaults] 部分中指定的选项始终处于选中状态.这不匹配的 for_repos 的存在没有相关性.请注意,您可能仍然使用 for_repos 值来提取有用的信息(更多关于这个之后).任何没有 for_repos 的用户定义组,或包含一个匹配的 for_repos,将被选择用于潜在用途.

存储库标识的用户定义组的子集进一步基于 for_paths 选项改进.如果至少选择一个组提交中的一个 path(*) 匹配 for_paths 正则表达式.笔记路径是相对于存储库的根目录,而不是有一个前导斜线.

The subset of user-defined groups identified by the repository are further refined based on the for_paths option. A group is selected if at least one path(*) in the commit matches the for_paths regular expression. Note that the paths are relative to the root of the repository and do not have a leading slash.

for_repos 的说法也适用于默认组的 for_paths.IE.for_paths 只对变量提取有用.

What is says for for_repos also applies to for_paths with respect to the defaults group. I.E. that that for_paths is only useful for variable extraction.

不进行任何代码更改的一种选择是将您的 [defaults] 中的 to_addr 设置为类似 [email protected] 的地址,您只需将其丢弃即可.然后使用不同的 to_addr 设置一个不同的组,该组实际上将被交付到某个地方.

One option without making any code changes would be to set your to_addr in your [defaults] to an address like [email protected] which you just throw away. Then set a different group up with a different to_addr that will actually be delivered someplace.

如果你愿意稍微修改你的 mailer.py,你可以通过在 Config 类的 which_groups 函数中注释掉以下两行来避免这种情况:

If you're willing to modify your mailer.py a tad you can avoid this by commenting out the following two lines in the which_groups function of the Config class:

if not groups:
  groups.append((None, self._default_params))

作为 Subversion 的长期开发人员,我认为我们应该在 mailer.py 中添加一个选项,以请求默认部分不生成邮件.此外,我们应该修复文档以更清楚地说明这种行为.

As a Subversion developer long term I think we should add an option to mailer.py to request that no mail be generated by the defaults section. Additionally, we should fix the documentation to be clearer about this behavior.

这篇关于SVN钩子mailer.py配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-25 10:45