cvs: CVSROOT / loginfo.pl
| From: | Sterling Hughes | Date: | Fri, 07 Sep 2001 23:37:42 +0000 |
| Subject: | cvs: CVSROOT / loginfo.pl | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-7295@lists.php.net to get a copy of this message | ||
sterling Fri Sep 7 19:37:42 2001 EDT
Modified files:
/CVSROOT loginfo.pl
Log:
Use Net::SMTP and enable sending commit messages to multiple addresses
Index: CVSROOT/loginfo.pl
diff -u CVSROOT/loginfo.pl:1.45 CVSROOT/loginfo.pl:1.46
--- CVSROOT/loginfo.pl:1.45 Thu Jun 28 19:30:28 2001
+++ CVSROOT/loginfo.pl Fri Sep 7 19:37:41 2001
@@ -57,43 +57,42 @@
&bail if $args[0] eq '-' && $args[1] eq 'Imported';
# find out the last directory being processed
-open FC, "$last_file.$id"
- or die "last file does not exist";
+open(FC, "$last_file.$id") || die "last file does not exist: $!\n";
my $last_directory = <FC>;
-chop $last_directory;
-close FC;
+chomp $last_directory;
+close(FC);
# remove the cvsroot from the front
$last_directory =~ s/^$cvsroot//;
# add our changed files to the summary
-open(FC, ">>$summary.$id") || die "cannot open summary file";
-foreach my $arg (@args) {
- print FC "$directory/$arg\n";
+open(FC, ">>$summary.$id") || die "cannot open summary file: $!\n";
+foreach (@args) {
+ print FC "$directory/$_\n";
}
close(FC);
# is this script already in the last changed directory?
# exit if this isn't the last directory
-&bail if($last_directory ne $directory);
+bail() if $last_directory ne $directory;
# get the log message and tag -- we throw away everything from STDIN
# before a line that begins with "Log Message"
-my ($logmsg,$tag) = &get_log_message();
+my ($logmsg,$tag) = get_log_message();
# now we fork off into the background and generate the email
-exit 0 if(fork() ne 0);
+exit 0 if fork() ne 0;
$| = 1;
#print "Reading summary file\n";
-open(FC, "<$summary.$id");
+open(FC, "$summary.$id") || die "Cannot open summary file: $!\n";
my (@added_files, @removed_files, @modified_files, @modified_files_info);
while (<FC>) {
- chop;
- my ($file, $old, $new) = split(",");
+ chomp;
+ my ($file, $old, $new) = split /,/;
if($old eq "NONE") {
push @added_files, $file;
} elsif($new eq "NONE") {
@@ -103,7 +102,7 @@
push @modified_files_info, [ $file, $old, $new ];
}
}
-close FC;
+close(FC);
#print "Unlinking helper files\n";
@@ -119,7 +118,8 @@
foreach my $info (@modified_files_info) {
my ($file, $old, $new) = @$info;
- open(LOG, "$cvs -Qn rdiff -r $old -r $new -u $file|") || die;
+ open(LOG, "$cvs -Qn rdiff -r $old -r $new -u $file|") ||
+ die "Cannot diff $file from revision $old to $new: $!\n";
while(<LOG>) { s/\r\n/\n/; $diffmsg .= $_; }
close(LOG);
}
@@ -130,7 +130,7 @@
next if $file =~ /\.(gif|jpe|jpe?g|pdf|png|exe|class|tgz|tar.gz|jar)$/i
or $file !~ /\./;
$diffmsg .= "\nIndex: $file\n+++ $file\n";
- open(LOG, "$cvs -Qn checkout -p -r1.1 $file |") || die;
+ open(LOG, "$cvs -Qn checkout -p -r1.1 $file |") || die "Cannot checkout $file:
$!\n";
while(<LOG>) { s/\r\n/\n/; $diffmsg .= $_; }
close(LOG);
}
@@ -169,15 +169,15 @@
my $msgid = "Message-ID: <cvs$cvsuser".time()."\@cvsserver>\n";
my %handles;
-if (open FD, $cvsusers) {
- while(<FD>) {
- chop;
- if (/^([a-z_]{2,}?)\s(.*)\s+([a-z0-9-\._]+@[a-z0-9-\.]+).*$/i) {
- $handles{$1} = [trim($2), trim($3)];
- }
+
+open(FD, $cvsusers) || die "Cannot open cvsusers file: $!\n";
+while(<FD>) {
+ chomp;
+ if (/^([a-z_]{2,}?)\s(.*)\s+([a-z0-9-\._]+@[a-z0-9-\.]+).*$/i) {
+ $handles{$1} = [trim($2), trim($3)];
}
- close(FD);
}
+close(FD);
my $from;
if(defined($handles{$cvsuser})) {
@@ -188,10 +188,10 @@
# "Reply-to: $mailto\n".
# "Date: ".localtime()."\n".
-my (@DAYABBR) = qw(Sun Mon Tue Wed Thu Fri Sat);
-my (@MONABBR) = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec);
+my @DAYABBR = qw(Sun Mon Tue Wed Thu Fri Sat);
+my @MONABBR = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec);
-my (@gmtime) = gmtime();
+my @gmtime = gmtime();
my $rfc822date = sprintf("Date: %s, %02d %s %d %02d:%02d:%02d -0000\n",
$DAYABBR[$gmtime[6]], $gmtime[3], $MONABBR[$gmtime[4]],
$gmtime[5] + 1900, $gmtime[2], $gmtime[1], $gmtime[0]);
@@ -210,7 +210,7 @@
"$cvsuser\t\t".localtime()." EDT\n".
"$msg".
" Log:\n".
- &indent($logmsg,2)."\n";
+ indent($logmsg,2)."\n";
my $boundary = $cvsuser.time();
@@ -247,23 +247,24 @@
#print $email;
-my $paddr = sockaddr_in($smtpport, inet_aton($smtpserver));
-socket(SOCK, PF_INET, SOCK_STREAM, 0) || die "socket failed";
-connect(SOCK, $paddr) || die "connect $smtpserver:$smtpport failed";
-select(SOCK);
-$|=1;
-
-print "HELO cvsserver\r\n".
-"MAIL FROM:<this-will-bounce\@php.net>\r\n".
-"RCPT TO:<$envaddr>\r\n".
-"DATA\r\n".
-"$email\r\n".
-".\r\n".
-"QUIT\r\n";
+# Send the commit message to the appropriate addresses
+{
+ require Net::SMTP;
+
+ my $smtp = Net::SMTP->new($smtpserver,
+ Hello => 'cvsserver');
+ $smtp->mail('this-will-bounce@php.net');
+ for (split(/,/, $envaddr)) {
+ $smtp->to($_);
+ }
+
+ $smtp->data();
+ $smtp->datasend($email . "\r\n");
+ $smtp->dataend();
-while(<SOCK>) { alarm(20); };
+ $smtp->quit();
+}
-close(SOCK);
exit 0;
sub get_log_message {