user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 5/5] www: repolist: support globbing in URL
Date: Tue, 16 Jan 2024 11:52:55 +0000	[thread overview]
Message-ID: <20240116115255.3554317-6-e@80x24.org> (raw)
In-Reply-To: <20240116115255.3554317-1-e@80x24.org>

This can make it easier to find deeply-nested repositories on my
mirror of git.kernel.org.  It's not perfect, since projects like
Linux use several completely different basenames (e.g. linux.git
vs vfs.git vs net.git), but it can still help find significant
matches further up a tree.

I don't expect glob characters to conflict with actual git
repositories used by reasonable people, but direct (non-glob)
hits are still tried first.
---
 lib/PublicInbox/RepoList.pm    | 4 ++--
 lib/PublicInbox/WwwCoderepo.pm | 6 +++++-
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/lib/PublicInbox/RepoList.pm b/lib/PublicInbox/RepoList.pm
index 4b313ed6..39dc9c0b 100644
--- a/lib/PublicInbox/RepoList.pm
+++ b/lib/PublicInbox/RepoList.pm
@@ -16,9 +16,9 @@ sub html_top_fallback { # WwwStream->html_repo_top
 }
 
 sub html ($$$) {
-	my ($wcr, $ctx, $pfx) = @_;
+	my ($wcr, $ctx, $re) = @_;
 	my $cr = $wcr->{pi_cfg}->{-coderepos};
-	my @nicks = grep(m!\A\Q$pfx\E/!, keys %$cr) or return; # 404
+	my @nicks = grep(m!$re!, keys %$cr) or return; # 404
 	__PACKAGE__->html_init($ctx);
 	my $zfh = $ctx->zfh;
 	print $zfh "<pre>matching coderepos\n";
diff --git a/lib/PublicInbox/WwwCoderepo.pm b/lib/PublicInbox/WwwCoderepo.pm
index 4ab9a77c..61aa7862 100644
--- a/lib/PublicInbox/WwwCoderepo.pm
+++ b/lib/PublicInbox/WwwCoderepo.pm
@@ -356,8 +356,12 @@ sub srv { # endpoint called by PublicInbox::WWW
 	} elsif ($path_info =~ m!\A/(.+?)/(refs/(?:heads|tags))/\z! and
 			($ctx->{git} = $pi_cfg->get_coderepo($1))) {
 		refs_foo($self, $ctx, $2);
+	} elsif ($path_info =~ m!\A/(.*?\*.*?)/*\z!) {
+		my $re = PublicInbox::Config::glob2re($1);
+		PublicInbox::RepoList::html($self, $ctx, qr!$re\z!) // r(404);
 	} elsif ($path_info =~ m!\A/(.+?)/\z!) {
-		PublicInbox::RepoList::html($self, $ctx, $1) // r(404);
+		my $re = qr!\A\Q$1\E/!;
+		PublicInbox::RepoList::html($self, $ctx, $re) // r(404);
 	} elsif ($path_info =~ m!\A/(.+?)\z! and
 			($git = $pi_cfg->get_coderepo($1))) {
 		my $qs = $ctx->{env}->{QUERY_STRING};

      parent reply	other threads:[~2024-01-16 11:52 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-16 11:52 [PATCH 0/5] www: coderepo updates Eric Wong
2024-01-16 11:52 ` [PATCH 1/5] tests: clarify Email::MIME is only for development Eric Wong
2024-01-16 11:52 ` [PATCH 2/5] examples/unsubscribe-milter@.service: use KillMode=process Eric Wong
2024-01-16 11:52 ` [PATCH 3/5] config: don't vivify invalid fields for coderepos Eric Wong
2024-01-16 11:52 ` [PATCH 4/5] config: glob2re: fix over-matching /**/foo Eric Wong
2024-01-16 11:52 ` Eric Wong [this message]

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: http://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=20240116115255.3554317-6-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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

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).