From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.2 required=3.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 6CDB81F527 for ; Tue, 4 Oct 2022 19:12:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1664910761; bh=sFNFpPv9ssKFs1VsYim7Py3QowFuOF3wgKrmcd+KN/4=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Gp+FuRJXTf+rdbCnoaLgBtziw328u0kbl8T0NH2OOrrl66bOk/3Ou5SxmAIycrHqG kduIP/tJKov4y95WfOxsDSRr+Ud9vy6v5pK+qSG/tQlK0XLqTqT5Tu+irN6YU6qZoC xwb+GnVx9OOoSeCfi3k8xS8gFtidNrKfwbV2YMBg= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 06/10] www_coderepo: wire up /$CODEREPO/$OID/s/ endpoint Date: Tue, 4 Oct 2022 19:12:36 +0000 Message-Id: <20221004191240.1056304-7-e@80x24.org> In-Reply-To: <20221004191240.1056304-1-e@80x24.org> References: <20221004191240.1056304-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: Just reusing ViewVCS::show, since encoding refname and pathnames into things just makes things slower. --- lib/PublicInbox/SolverGit.pm | 8 ++++---- lib/PublicInbox/ViewVCS.pm | 1 + lib/PublicInbox/WwwCoderepo.pm | 4 ++++ 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/PublicInbox/SolverGit.pm b/lib/PublicInbox/SolverGit.pm index b723b48a..80bb0a17 100644 --- a/lib/PublicInbox/SolverGit.pm +++ b/lib/PublicInbox/SolverGit.pm @@ -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; } diff --git a/lib/PublicInbox/ViewVCS.pm b/lib/PublicInbox/ViewVCS.pm index b0f58455..6ada03e6 100644 --- a/lib/PublicInbox/ViewVCS.pm +++ b/lib/PublicInbox/ViewVCS.pm @@ -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 { diff --git a/lib/PublicInbox/WwwCoderepo.pm b/lib/PublicInbox/WwwCoderepo.pm index 4b1a4f9b..e0fc9045 100644 --- a/lib/PublicInbox/WwwCoderepo.pm +++ b/lib/PublicInbox/WwwCoderepo.pm @@ -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});