Skip Menu |
 

This queue is for tickets about the activitymail CPAN distribution.

Report information
The Basics
Id: 5844
Status: resolved
Priority: 0/
Queue: activitymail

People
Owner: dwheeler [...] cpan.org
Requestors: warlord [...] mit.edu
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 1.19
Fixed in: (no value)

Attachments


Subject: Add '-T' option to allow two email messages
Download (untitled) / with headers
text/plain 443b
I want to be able to send out two messages for every commit. One message includes a diff of the changes and one message does not. This patch adds a '-T' option which is only 'valid' in conjunction with -dc. If the user supplies -T <email2> then a message without diffs will be sent to <email2> (and the log with diffs will continue to be sent to <email> as defined by -t). I'm running with this patch locally and it works for me. Thanks!
Download activitymail.diff
text/x-diff 5.5k
Index: activitymail =================================================================== RCS file: /home/cvs/cvsroot/CVSROOT/activitymail,v retrieving revision 1.28 retrieving revision 1.34 diff -u -r1.28 -r1.34 --- activitymail 11 Mar 2004 17:22:04 -0000 1.28 +++ activitymail 31 Mar 2004 04:19:11 -0000 1.34 @@ -3,7 +3,7 @@ eval 'exec /usr/bin/perl -w -S $0 ${1+"$@"}' if 0; # not running under some shell -# $Id: activitymail,v 1.28 2004/03/11 17:22:04 theory Exp $ +# $Id: activitymail,v 1.34 2004/03/31 04:19:11 warlord Exp $ use strict; require 5.005; @@ -37,9 +37,9 @@ use vars qw($opt_f $opt_r $opt_l $opt_m $opt_t $opt_n $opt_i $opt_p $opt_c $opt_s $opt_h $opt_d $opt_a $opt_D $opt_o $opt_e $opt_u $opt_g $opt_w $opt_H $opt_B $opt_j $opt_M $opt_S $opt_v $opt_V $opt_N - $opt_I $opt_E $opt_q $opt_Q + $opt_I $opt_E $opt_q $opt_Q $opt_T ); - getopts('f:lr:m:t:nipcs:dhaDo:e:u:gw:HB:j:M:SvVN:I:E:qQ'); + getopts('f:lr:m:t:nipcs:dhaDo:e:u:gw:HB:j:M:SvVN:I:E:qQT:'); } ############################################################################## @@ -344,39 +344,44 @@ sub mail { my ($subject, $body) = @_; + mail_to($opt_t, $opt_a, $subject, $body); + exit; +} + +sub mail_to { + my ($dest, $do_attach, $subject, $body) = @_; # Over max size? if ($opt_M and (length($body) / 1024) > $opt_M) { exit if $opt_Q; - print "*** Not sending mail to $opt_t!\n"; + print "*** Not sending mail to $dest!\n"; print "*** The message is ", int(length($body) / 1024), "k long and maximum message size is ${opt_M}k.\n"; exit; } - print "Sending mail to $opt_t..." unless $opt_q; + print "Sending mail to $dest..." unless $opt_q; $opt_s ||= find_sendmail() or mydie("Cannot find sendmail. Use -s.\n"); open(SENDMAIL, "|$opt_s -oi -t") or mydie("Cannot fork for sendmail: $!\n"); print SENDMAIL "MIME-Version: 1.0\n"; print SENDMAIL "From: $opt_u\n" if $opt_u; - print SENDMAIL "To: $opt_t\nSubject: $subject\n"; + print SENDMAIL "To: $dest\nSubject: $subject\n"; print SENDMAIL "Reply-To: $opt_r\n" if $opt_r; print SENDMAIL "X-Mailer: activitymail $VERSION, " . "http://search.cpan.org/dist/activitymail/\n"; - if ($opt_a) { - print SENDMAIL qq{Content-Type: multipart/mixed; boundary="$opt_a"\n\n} - . "--$opt_a\nContent-Type: $ctype\n"; + if ($do_attach) { + print SENDMAIL qq{Content-Type: multipart/mixed; boundary="$do_attach"\n\n} + . "--$do_attach\nContent-Type: $ctype\n"; } else { print SENDMAIL "Content-Type: $ctype\n"; } print SENDMAIL "\n$$body"; - print SENDMAIL "--$opt_a--\n" if $opt_a; + print SENDMAIL "--$do_attach--\n" if $do_attach; close SENDMAIL; print "Done\n" unless $opt_q; # Delete any temp files. - exit; } ############################################################################## @@ -536,14 +541,18 @@ # Grab the diffs for the latest files. $files->{rev} .= get_diffs($revs); my $subject = mk_subject($msg, $mod, $files); - mail($subject, build_msg($msg, $files, $revs, $subject, $tags)); + mail_to($opt_t, $opt_a, $subject, + build_msg($opt_d, $msg, $files, $revs, $subject, $tags)); + mail_to($opt_T, '', $subject, + build_msg('', $msg, $files, $revs, $subject, $tags)) + if ($opt_T); exit; } } else { # No need for diffs. Just send it as is. $files = get_files($files) or exit; my $subject = mk_subject($msg, $mod, $files); - mail($subject, build_msg($msg, $files, $revs, $subject, $tags)); + mail($subject, build_msg($opt_d, $msg, $files, $revs, $subject, $tags)); exit; } # Exit the parent process. @@ -629,25 +638,27 @@ ############################################################################## # This function takes an existing message, a files href, and the message -# suject as arguments, and returns a fully formatted message that includes the +# subject as arguments, and returns a fully formatted message that includes the # list of files. The subject is used for attachments (see attach() below). ############################################################################## sub build_msg { + my ($do_diffs, @rest) = @_; + DEBUG && dbpnt("Building message body.\n"); if ($opt_H) { - $msg = build_html_msg(@_); + $msg = build_html_msg(@rest); } else { - $msg = build_text_msg(@_); + $msg = build_text_msg(@rest); } # Okay, now add the diffs. - if ($opt_d) { + if ($do_diffs) { # Make it either an attachment or inline, depending on -a. - $$msg .= $opt_a ? attach($_[3]) : + $$msg .= $opt_a ? attach($rest[3]) : "\n$map{rev}\n" . '-' x length($map{rev}). "\n"; # Attach those diffs! - $$msg .= $_[1]->{rev}; + $$msg .= $rest[1]->{rev}; } return $msg; } @@ -908,6 +919,7 @@ -c Commit mode. Required unless -l. -f %{sVv} The file spec argument from CVS. Required unless -l -t <email> The notification destination email address. Required unless -l. + -T <email> Secondary email for comments without diffs, only valid with -d. -e <cvs> Location of CVS executable. Defaults to "cvs" (i.e., in path). -d Include the diffs for all the files processed. -j Location of diff executable. Defaults to "diff" (i.e., in path).
Download (untitled) / with headers
text/plain 177b
This is a pretty specialized patch. I don't think that I'd apply it, but you might be able to get something out of the suggestion in Ticket # 16299—if it was ever implemented.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.