]> Sergey Matveev's repositories - public-inbox.git/commitdiff
lei blob: support "lei index"-ed mail
authorEric Wong <e@80x24.org>
Wed, 5 May 2021 10:46:38 +0000 (10:46 +0000)
committerEric Wong <e@80x24.org>
Wed, 5 May 2021 17:45:17 +0000 (17:45 +0000)
Normal git retrieval don't work for Maildir blobs indexed using
"lei index".  Fortunately, this oddness is limited to the
LeiStore class and we can override smsg_eml with a fallback
to read blobs from Maildirs.

lib/PublicInbox/LeiSearch.pm
t/solver_git.t

index cd28a700647bf62a37655108d9fb1467f776fbcc..c2b1214679f012478dcb3bd34753cf8cefb6b4b7 100644 (file)
@@ -144,4 +144,14 @@ sub lms {
        -f $f ? PublicInbox::LeiMailSync->new($f) : undef;
 }
 
+# allow SolverGit->resolve_patch to work with "lei index"
+sub smsg_eml {
+       my ($self, $smsg) = @_;
+       PublicInbox::Inbox::smsg_eml($self, $smsg) // do {
+               my $lms = lms($self);
+               my $bref = $lms ? $lms->local_blob($smsg->{blob}, 1) : undef;
+               $bref ? PublicInbox::Eml->new($bref) : undef;
+       };
+}
+
 1;
index e566efb31674f444fa44698554057922a696127b..44cbbfdb2adb04aa34744801d6da97ff490acc9d 100644 (file)
@@ -27,6 +27,11 @@ my $ibx = create_inbox 'v2', version => 2,
        $im->add(eml_load 't/solve/0001-simple-mod.patch') or BAIL_OUT;
        $im->add($patch2) or BAIL_OUT;
 };
+my $md = "$tmpdir/md";
+File::Path::mkpath([map { $md.$_ } (qw(/ /cur /new /tmp))]);
+symlink(abs_path('t/solve/0001-simple-mod.patch'), "$md/cur/foo:2,") or
+       xbail "symlink: $!";
+
 my $v1_0_0_tag = 'cb7c42b1e15577ed2215356a2bf925aef59cdd8d';
 my $v1_0_0_tag_short = substr($v1_0_0_tag, 0, 16);
 my $expect = '69df7d565d49fbaaeb0a067910f03dc22cd52bd0';
@@ -70,6 +75,11 @@ test_lei({tmpdir => "$tmpdir/rediff"}, sub {
                'got more context with -U9');
 });
 
+test_lei({tmpdir => "$tmpdir/index-eml-only"}, sub {
+       lei_ok(qw(index), $md);
+       lei_ok(qw(blob 69df7d5)); # hits LeiSearch->smsg_eml -> lms->local_blob
+});
+
 my $git = PublicInbox::Git->new($git_dir);
 $ibx->{-repo_objs} = [ $git ];
 my $res;