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/;
8 use PublicInbox::Inbox;
9 use PublicInbox::V2Writable;
10 use PublicInbox::Import;
11 my $usage = "usage: $0 NAME EMAIL DIR <MBOX\n";
15 'n|dry-run' => \$dry_run,
16 'V|version=i' => \$version,
18 GetOptions(%opts) or die $usage;
19 my $name = shift or die $usage; # git
20 my $email = shift or die $usage; # git@vger.kernel.org
21 my $mainrepo = shift or die $usage; # /path/to/v2/repo
23 mainrepo => $mainrepo,
26 -primary_address => $email,
28 $ibx = PublicInbox::Inbox->new($ibx);
32 $im = PublicInbox::V2Writable->new($ibx, 1);
34 system(qw(git init --bare -q), $mainrepo);
35 my $git = PublicInbox::Git->new($mainrepo);
36 $im = PublicInbox::Import->new($git, $name, $email, $ibx);
41 use PublicInbox::Filter::Vger;
42 my $vger = PublicInbox::Filter::Vger->new;
46 $$msg =~ s/(\r?\n)+\z/$1/s;
47 my $mime = PublicInbox::MIME->new($msg);
48 $mime = $vger->scrub($mime);
52 $mime->header_obj->header_raw('Message-ID'), "\n";
55 # asctime: From example@example.com Fri Jun 23 02:56:55 2000
56 my $from_strict = qr/^From \S+ +\S+ \S+ +\S+ [^:]+:[^:]+:[^:]+ [^:]+/;
58 while (defined(my $l = <STDIN>)) {
59 if ($l =~ /$from_strict/o) {
60 if (!defined($prev) || $prev =~ /^\r?$/) {
61 do_add($im, \$msg) if $msg;
71 do_add($im, \$msg) if $msg;