From 94071606e08a69340160171aa67236cb4fe2bafb Mon Sep 17 00:00:00 2001 From: Peter Palfrader Date: Sat, 18 May 2013 15:18:35 +0000 Subject: Modernize parse-git, can handle encoded from lines now git-svn-id: svn+ssh://asteria.noreply.org/svn/weaselutils/trunk@624 bc3d92e2-beff-0310-a7cd-cc87d7ac0ede --- parse-git | 42 ++++++++++++------------------------------ 1 file changed, 12 insertions(+), 30 deletions(-) (limited to 'parse-git') diff --git a/parse-git b/parse-git index 84afd5b..a0e5f49 100755 --- a/parse-git +++ b/parse-git @@ -1,6 +1,6 @@ #!/usr/bin/perl -wT -# Copyright (c) 2005, 2006, 2007, 2008 Peter Palfrader +# Copyright (c) 2005, 2006, 2007, 2008, 2013 Peter Palfrader # Copyright (c) 2007, 2008 Joerg Jaspert # # Permission is hereby granted, free of charge, to any person obtaining @@ -28,6 +28,8 @@ use strict; use English; use MIME::Base64; use File::Basename; +use Mail::Message; +use Encode; my $MAX_LINES = 4; my $ENVELOPE_FROM = 'nobody@commit.noreply.org'; @@ -47,36 +49,14 @@ $project =~ m/^([a-zA-Z-]+(\.[a-zA-Z-]+)*)+$/; $project = $1; die ("Project is not a nice name.\n") unless defined $project; -my $subject; -my $who; -my $date; -my $author; - open (MAIL, $ARGV[1]) || die ("Cannot open $ARGV[1]: $!\n"); -my @mail = ; +my $email = Mail::Message->read(\*MAIL); close(MAIL); -my $line; - - -while (defined($line = shift @mail)) { - my $chomped = $line; - chomp $chomped; - last if $chomped eq ''; - if ($chomped =~ m/^Subject: (.*)/) { - $subject = $1; - next; - } elsif ($chomped =~ m/^Date: (.*)/) { - $date = $1; - next; - } elsif ($chomped =~ m/^From: (.*)/) { - $who = $1; - next; - } elsif ($chomped =~ m/^Patch-Author: (.*)/) { - $author = $1; - next; - } -} +my $subject = $email->subject; +my $date = $email->head->get('Date'); +my $who = Encode::decode("MIME-Header", ($email->from)[0]->format); +my $author = $email->get("Path-Author"); die ("$PROGRAM_NAME - $project: No author found.\n") unless defined $who; die ("$PROGRAM_NAME - $project: No subject found.\n") unless defined $subject; @@ -89,18 +69,20 @@ print MAIL "From: $HEADER_FROM\n"; print MAIL "To: $BOT_ADDRESS\n"; print MAIL "Subject: Announce $project\n"; print MAIL "Precedence: junk\n"; +print MAIL "Content-Type: text/plain; charset=UTF-8\n"; +print MAIL "Content-Transfer-Encoding: base64\n"; print MAIL "\n"; my $at; if (defined $date) { $at = " at $date"; } -my $by; +my $by=''; if (defined $author) { $by = " by $author"; } $subject =~ s/^\[or-cvs\] *//; $subject =~ s/\[([^\]]*)\] /to $1: /; -print MAIL "$who committed patch$by$at $subject\n"; +print MAIL encode_base64(Encode::encode('utf-8', "$who committed patch$by$at $subject\n")); close(MAIL); -- cgit v1.2.3