]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/Inbox.pm
search: support alt-ID for mapping legacy serial numbers
[public-inbox.git] / lib / PublicInbox / Inbox.pm
index 23b77213b7a9d1b3adf4b8598ddca22035dea4a3..922ca9bbdc78c297e8c690fee95cd7c6b34243bb 100644 (file)
@@ -87,7 +87,7 @@ sub search {
        my ($self) = @_;
        $self->{search} ||= eval {
                _weaken_later($self);
-               PublicInbox::Search->new($self->{mainrepo});
+               PublicInbox::Search->new($self->{mainrepo}, $self->{altid});
        };
 }
 
@@ -106,6 +106,7 @@ sub description {
        my $desc = $self->{description};
        return $desc if defined $desc;
        $desc = try_cat("$self->{mainrepo}/description");
+       local $/ = "\n";
        chomp $desc;
        $desc =~ s/\s+/ /smg;
        $desc = '($GIT_DIR/description missing)' if $desc eq '';
@@ -118,6 +119,7 @@ sub cloneurl {
        return $url if $url;
        $url = try_cat("$self->{mainrepo}/cloneurl");
        my @url = split(/\s+/s, $url);
+       local $/ = "\n";
        chomp @url;
        $self->{cloneurl} = \@url;
 }
@@ -160,6 +162,18 @@ sub msg_by_path ($$;$) {
        $str;
 }
 
+sub msg_by_smsg ($$;$) {
+       my ($self, $smsg, $ref) = @_;
+
+       # backwards compat to fallback to msg_by_mid
+       # TODO: remove if we bump SCHEMA_VERSION in Search.pm:
+       defined(my $blob = $smsg->blob) or return msg_by_mid($self, $smsg->mid);
+
+       my $str = git($self)->cat_file($blob, $ref);
+       $$str =~ s/\A[\r\n]*From [^\r\n]*\r?\n//s if $str;
+       $str;
+}
+
 sub path_check {
        my ($self, $path) = @_;
        git($self)->check('HEAD:'.$path);