2 # Copyright (C) 2016-2018 all contributors <meta@public-inbox.org>
3 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
6 use Getopt::Long qw/:config gnu_getopt no_ignore_case auto_abbrev/;
7 use Date::Parse qw/str2time/;
9 use PublicInbox::Inbox;
10 use PublicInbox::V2Writable;
11 use PublicInbox::Import;
12 my $usage = "usage: $0 NAME EMAIL DIR <MBOX\n";
16 'n|dry-run' => \$dry_run,
17 'V|version=i' => \$version,
19 GetOptions(%opts) or die $usage;
20 my $name = shift or die $usage; # git
21 my $email = shift or die $usage; # git@vger.kernel.org
22 my $mainrepo = shift or die $usage; # /path/to/v2/repo
24 mainrepo => $mainrepo,
27 -primary_address => $email,
29 $ibx = PublicInbox::Inbox->new($ibx);
33 $im = PublicInbox::V2Writable->new($ibx, 1);
35 system(qw(git init --bare -q), $mainrepo);
36 my $git = PublicInbox::Git->new($mainrepo);
37 $im = PublicInbox::Import->new($git, $name, $email, $ibx);
42 use PublicInbox::Filter::Vger;
43 my $vger = PublicInbox::Filter::Vger->new;
47 $$msg =~ s/(\r?\n)+\z/$1/s;
48 my $mime = PublicInbox::MIME->new($msg);
49 $mime = $vger->scrub($mime);
53 $mime->header_obj->header_raw('Message-ID'), "\n";
56 # asctime: From example@example.com Fri Jun 23 02:56:55 2000
57 my $from_strict = qr/^From \S+ +\S+ \S+ +\S+ [^:]+:[^:]+:[^:]+ [^:]+/;
59 while (defined(my $l = <STDIN>)) {
60 if ($l =~ /$from_strict/o) {
61 if (!defined($prev) || $prev =~ /^\r?$/) {
62 do_add($im, \$msg) if $msg;
72 do_add($im, \$msg) if $msg;