summaryrefslogtreecommitdiff
path: root/parse-git
diff options
context:
space:
mode:
authorPeter Palfrader <peter@palfrader.org>2013-05-18 15:18:35 +0000
committerweasel <weasel@bc3d92e2-beff-0310-a7cd-cc87d7ac0ede>2013-05-18 15:18:35 +0000
commit94071606e08a69340160171aa67236cb4fe2bafb (patch)
tree4b559562d5ed04ee5fbc476d85e2b3a9d3691a18 /parse-git
parent608dc87f8f6ac2e9d2f37075d1db8bb2a45ebdeb (diff)
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
Diffstat (limited to 'parse-git')
-rwxr-xr-xparse-git42
1 files changed, 12 insertions, 30 deletions
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 <peter@palfrader.org>
+# Copyright (c) 2005, 2006, 2007, 2008, 2013 Peter Palfrader <peter@palfrader.org>
# Copyright (c) 2007, 2008 Joerg Jaspert <joerg@debian.org>
#
# 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 = <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);