unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
From: Eric Wong <e@80x24.org>
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	[thread overview]
Message-ID: <20221004191240.1056304-7-e@80x24.org> (raw)
In-Reply-To: <20221004191240.1056304-1-e@80x24.org>

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});

  parent reply	other threads:[~2022-10-04 19:12 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-04 19:12 [PATCH 00/10] www_coderepo: git viewer w/ search planned Eric Wong
2022-10-04 19:12 ` [PATCH 01/10] tests: use test_httpd consistently Eric Wong
2022-10-04 19:12 ` [PATCH 02/10] cgit: use Perl 5.10-isms, optimize, and golf Eric Wong
2022-10-04 19:12 ` [PATCH 03/10] git: hoist out description Eric Wong
2022-10-04 19:12 ` [PATCH 04/10] git: move cloneurl + description reading here Eric Wong
2022-10-04 19:12 ` [PATCH 05/10] www_coderepo: an alternative to cgit Eric Wong
2022-10-04 19:12 ` Eric Wong [this message]
2022-10-04 19:12 ` [PATCH 07/10] git: allow ->local_nick to return undef Eric Wong
2022-10-04 19:12 ` [PATCH 08/10] www_coderepo: wire up snapshot support Eric Wong
2022-10-04 19:12 ` [PATCH 09/10] www_stream: use git->pub_urls for coderepo links Eric Wong
2022-10-04 23:01   ` [PATCH 11/10] www_stream: pass $env to git->pub_urls Eric Wong
2022-10-04 19:12 ` [PATCH 10/10] www_coderepo: start a top nav bar in summary view Eric Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://public-inbox.org/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221004191240.1056304-7-e@80x24.org \
    --to=e@80x24.org \
    --cc=meta@public-inbox.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).