]> Sergey Matveev's repositories - public-inbox.git/commitdiff
www_coderepo: wire up /$CODEREPO/$OID/s/ endpoint
authorEric Wong <e@80x24.org>
Tue, 4 Oct 2022 19:12:36 +0000 (19:12 +0000)
committerEric Wong <e@80x24.org>
Wed, 5 Oct 2022 21:15:26 +0000 (21:15 +0000)
Just reusing ViewVCS::show, since encoding refname and pathnames
into things just makes things slower.

lib/PublicInbox/SolverGit.pm
lib/PublicInbox/ViewVCS.pm
lib/PublicInbox/WwwCoderepo.pm

index b723b48a9f6545ef7724b5605666a53ab3d7b361..80bb0a178fb540f507a596246574a45416846872 100644 (file)
@@ -639,7 +639,7 @@ sub resolve_patch ($$) {
 
        # scan through inboxes to look for emails which results in
        # the oid we want:
-       my $ibx = shift(@{$want->{try_ibxs}}) or die 'BUG: {try_ibxs} empty';
+       my $ibx = shift(@{$want->{try_ibxs}}) or return done($self, undef);
        if (my $msgs = find_smsgs($self, $ibx, $want)) {
                $want->{try_smsgs} = $msgs;
                $want->{cur_ibx} = $ibx;
@@ -654,14 +654,14 @@ sub resolve_patch ($$) {
 sub new {
        my ($class, $ibx, $user_cb, $uarg) = @_;
 
-       bless {
-               gits => $ibx->{-repo_objs},
+       bless { # $ibx is undef if coderepo only (see WwwCoderepo)
+               gits => $ibx ? $ibx->{-repo_objs} : undef,
                user_cb => $user_cb,
                uarg => $uarg,
                # -cur_di, -qsp_err, -msg => temp fields for Qspawn callbacks
 
                # TODO: config option for searching related inboxes
-               inboxes => [ $ibx ],
+               inboxes => $ibx ? [ $ibx ] : [],
        }, $class;
 }
 
index b0f58455018b0ea03d97ddd42a377cccd927fd82..6ada03e6fb1d5d4aa2a45a26a63676284d7cb165 100644 (file)
@@ -484,6 +484,7 @@ sub show ($$;$) {
        open $ctx->{lh}, '+>>', "$ctx->{-tmp}/solve.log" or die "open: $!";
        my $solver = PublicInbox::SolverGit->new($ctx->{ibx},
                                                \&solve_result, $ctx);
+       $solver->{gits} //= [ $ctx->{git} ];
        $solver->{tmp} = $ctx->{-tmp}; # share tmpdir
        # PSGI server will call this immediately and give us a callback (-wcb)
        sub {
index 4b1a4f9baeb2b00ad03e84a35122605e58ecaa81..e0fc90459d209b1a7299a550f09235723880d360 100644 (file)
@@ -171,6 +171,10 @@ sub srv { # endpoint called by PublicInbox::WWW
        }
        $path_info =~ m!\A/(.+?)/\z! and
                ($ctx->{git} = $self->{"\0$1"}) and return summary($self, $ctx);
+       $path_info =~ m!\A/(.+?)/([a-f0-9]+)/s/\z! and
+                       ($ctx->{git} = $self->{"\0$1"}) and
+               return PublicInbox::ViewVCS::show($ctx, $2);
+
        if ($path_info =~ m!\A/(.+?)\z! and ($git = $self->{"\0$1"})) {
                my $qs = $ctx->{env}->{QUERY_STRING};
                my $url = $git->base_url($ctx->{env});