SVN-hooker.py mailbox configuration

I am trying to configure a post-commit hook on a subversion 1.6.12 server to send a commit notification message.

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

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

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

[general] smtp_hostname = xxx.xxx.xxx.xxx [defaults] from_addr = myemail@domain.tld to_addr = myemail@domain.tld 

And this is what I was trying to configure for mail in / tags / only:

 [general] smtp_hostname = xxx.xxx.xxx.xxx [defaults] from_addr = myemail@domain.tld to_addr = myemail@domain.tld for_paths = .*/tags/.* 

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

Any idea? Thanks.

+4
source share
3 answers

There really is no good way to do this. mailer.py is designed so that any commit that does not correspond to another group falls into the default group.

The documentation in mailer.conf.example alludes to this, but doesn't really explain it very well:

The options specified in the [default] section are always selected. the presence of for_repos mismatch is irrelevant. Note that you can still use the for_repos value to extract useful information (more on this later). Any user groups without for_repos or which contain for possible use the corresponding for_repos will be selected.

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

What is specified for for_repos also applies to for_paths relative to the default group. I.E. which for for_paths is only useful for extracting a variable.

One option without making any code changes is to set to_addr in [default] to an address, such as devnull@example.com , which you just throw away. Then set another group with a different to_addr value that will actually be delivered somewhere.

If you want to change your mailer.py tad, you can avoid this by commenting on the following two lines in the which_groups function of the Config class:

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

As a Subversion developer for a long time, I think we should add the mailer.py option to request that no mail be generated by the default section. In addition, we must correct the documentation to be clearer in this behavior.

+4
source

Finally, I solved the problem using another script notification available in the utils folder (even if it is deprecated): commit-email.pl

Using this as in my post-commit hook works as expected:

 REPOS="$1" REV="$2" LC_ALL=C /usr/share/subversion/hook-scripts/commit-email.pl "$REPOS" $REV -m "tags/.*" -s "[TAGS]" --from noreply@domain.tld myemail@domain.tld 

But if someone has the right setup to do the same with mailer.py, I'm still interested!

0
source

Instead:

 for_paths = .*/tags/.* 

Try the following:

 for_paths = ^tags($|.*) 

The dir tag is supposed to be at the root of your repository.

If you have tags under the project, it will be like

 for_paths = ^<project name>/tags($|.*) 
0
source

All Articles