From 008ef39d627e5c5e8308f188bbdfac1bd544d004 Mon Sep 17 00:00:00 2001 From: Bas Zoetekouw Date: Mon, 29 Sep 2008 23:26:01 +0000 Subject: Fix mailing of check_trans updates: - actually parse the argument to -m - fix the format of log output (still had svn revisions) - fix encoding of mails - fix overly verbose errors CVS version numbers check_trans.pl: 1.65 -> 1.66 --- check_trans.pl | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) (limited to 'check_trans.pl') diff --git a/check_trans.pl b/check_trans.pl index cdab7b638d9..8e96437df73 100755 --- a/check_trans.pl +++ b/check_trans.pl @@ -327,16 +327,21 @@ sub verbose; if ( $status != ST_MISSING ) { $maxdelta ||= $translators{maxdelta}{maxdelta} || 5; - my $delta = vcs_count_changes( $file_orig, $rev_transl, 'HEAD' ); - - push @{ $emails_to_send{'maxdelta'} }, { - 'file' => $file, - 'status' => $status, - 'info' => $str, - 'delta' => $delta, - 'last_trans_rev' => $rev_transl, + + my $delta = undef; + if ( -e $file_orig ) + { + $delta = vcs_count_changes( $file_orig, $rev_transl, 'HEAD' ); + + push @{ $emails_to_send{'maxdelta'} }, { + 'file' => $file, + 'status' => $status, + 'info' => $str, + 'delta' => $delta, + 'last_trans_rev' => $rev_transl, + } + if ( $delta >= $maxdelta ); } - if ( $delta >= $maxdelta ); } } @@ -439,10 +444,12 @@ sub send_email } # and attach the body to the mail - $msg->attach( - 'Type' => 'TEXT', + my $part = MIME::Lite->new( + 'Type' => 'text/plain', 'Data' => $body, ); + $part->attr( 'content-type.charset' => 'utf-8' ); + $msg->attach( $part ); # attach part about NeedToUpdate files my $text = ''; @@ -548,7 +555,7 @@ sub send_email my $rev = $file->{'last_trans_rev'}; my $log = get_log( $filename, $rev, 'HEAD' ); my $part = MIME::Lite->new( - 'Type' => 'TEXT', + 'Type' => 'TEXT', 'Filename' => "$filename.log", 'Data' => $log, 'Encoding' => 'quoted-printable', @@ -645,7 +652,7 @@ sub get_log { chomp $l->{'message'}; - $str .= sprintf( "r%d | %s | %s\n", + $str .= sprintf( "%s | %s | %s\n", $l->{'rev'}, $l->{'author'}, scalar localtime $l->{'date'} ); $str .= "\n"; $str .= $l->{'message'} . "\n"; @@ -744,7 +751,7 @@ sub parse_cmdargs $OPT{s} = ''; # parse options - if ( not getopts( 'adghmn:p:qs:TvV', \%OPT ) ) + if ( not getopts( 'adghm:n:p:qs:TvV', \%OPT ) ) { show_help(); exit -1; @@ -773,7 +780,7 @@ sub parse_cmdargs if ( $OPT{'m'} and $OPT{'n'} !~ m{^[123]$} ) { - die "Invalid priority. Please set -n value to 1, 2 or 3.\n" + die "Invalid priority `$OPT{n}'. Please set -n value to 1, 2 or 3.\n" ."(assuming you know what you're doing)\n"; } -- cgit v1.2.3