]> Sergey Matveev's repositories - public-inbox.git/commitdiff
mda: set GIT_{COMMITTER,AUTHOR}_{NAME,EMAIL} env
authorEric Wong <e@80x24.org>
Wed, 9 Apr 2014 19:33:06 +0000 (19:33 +0000)
committerEric Wong <e@80x24.org>
Wed, 9 Apr 2014 19:33:06 +0000 (19:33 +0000)
This can make it easy to query via "git log --author=..."
without extracting each message.

public-inbox-mda

index 70fbdf27faded071df827f9af0bea765dcd798f3..14017f68d265cf4fc4c9bde3864136f61dc18d49 100755 (executable)
@@ -41,7 +41,20 @@ if (PublicInbox->precheck($filter, $recipient) &&
        if (PublicInbox::Filter->run($simple)) {
                # run spamc again on the HTML-free message
                if (do_spamc($simple, \$filtered)) {
-                       $filter->simple(Email::Simple->new($filtered));
+                       $simple = Email::Simple->new($filtered);
+                       $filter->simple($simple);
+
+                       my $from = $filter->from;
+                       my @from = Email::Address->parse($from);
+                       my $name = $from[0]->name;
+                       defined $name or $name = "";
+                       my $email = $from[0]->address;
+                       defined $email or $email = "";
+                       local $ENV{GIT_AUTHOR_NAME} = $name;
+                       local $ENV{GIT_AUTHOR_EMAIL} = $email;
+                       local $ENV{GIT_COMMITTER_EMAIL} = $recipient;
+                       local $ENV{GIT_COMMITTER_NAME} = $dst->{listname};
+
                        $filter->pipe(MDA, '-1', $main_repo);
                }
        }