]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
www: repolist: support globbing in URL
authorEric Wong <e@80x24.org>
Tue, 16 Jan 2024 11:52:55 +0000 (11:52 +0000)
committerEric Wong <e@80x24.org>
Wed, 17 Jan 2024 09:37:55 +0000 (09:37 +0000)
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
lib/PublicInbox/WwwCoderepo.pm

index 4b313ed6481526afa3fe35ca9de175baf1c5340c..39dc9c0bfcb8d8ef21404a3ee6fc7ebb6407e098 100644 (file)
@@ -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";
index 4ab9a77c6d3d3af1fddb736c08e1b639f57917cd..61aa78620c90cbf1e1e335098bf8dadd4a8fadae 100644 (file)
@@ -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};