Subject: | Enhance regexp-map/email-map do use groups from the matched regexp |
Hi,
Currently, the email target for a matching regex (-x) is static. For
more flexibility, it should be possible to specify groups from the
matched regexp as components of the email address.
Attached is a diff that implements this in a hackish way (sorry, my Perl
foo is not good). It might be possible to do this in a better way (e.g.
without re-doing the pattern match, or without $&), but I hope my patch
explains the desired behaviour.
regards,
iustin
Subject: | svnnotify-regex-groups2.patch |
Index: lib/SVN/Notify.pm
===================================================================
--- lib/SVN/Notify.pm (revision 4848)
+++ lib/SVN/Notify.pm (working copy)
@@ -1138,7 +1138,11 @@
# If the directory matches the regex, save the email.
if (/$rx/) {
$self->_dbpnt( qq{"$_" matched $rx}) if $self->{verbose} > 2;
- push @$tos, $email unless $seen{$email}++;
+ # replace $1, $2, ... in the email with any matched groups
+ my @repl = /$rx/;
+ my $fix_email = $email;
+ $fix_email =~ s/\$(\d+)/$repl[$1-1] || $&/eg;
+ push @$tos, $fix_email unless $seen{$fix_email}++;
}
}
# Grab the context if it's needed for the subject.