From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.2 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, T_SCC_BODY_TEXT_LINE shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 3363C1F677 for ; Tue, 16 Jan 2024 11:52:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1705405976; bh=jBNkyYlNtppm7FoZEiu+C6j5vMAH2goQNPWLSGwam3s=; h=From:To:Subject:Date:In-Reply-To:References:From; b=HMDQQa/zU53iJH870jwPw/tybn/UCQNR5nq05d9BU7VaETUjKfbcaI/l/UkZfpVB6 EfIk2KRppgh02rdt/2/hOktIGF2cttOP/AoMmwu+y63f24pLfXAdC37791l4VdUaq9 brSv49epwFKKwSwpVcn4gFEVkwr4GQxbZ70oulhE= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 5/5] www: repolist: support globbing in URL Date: Tue, 16 Jan 2024 11:52:55 +0000 Message-ID: <20240116115255.3554317-6-e@80x24.org> In-Reply-To: <20240116115255.3554317-1-e@80x24.org> References: <20240116115255.3554317-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: 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 "
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};