user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download mbox.gz: |
* [PATCH 2/2] config: glob2re supports `**' to match multiple path components
  2023-03-17 20:31  5% [PATCH 0/2] globbing updates Eric Wong
@ 2023-03-17 20:31  7% ` Eric Wong
  0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2023-03-17 20:31 UTC (permalink / raw)
  To: meta

This should match behavior documented in gitglossary(7)
---
 lib/PublicInbox/Config.pm | 3 ++-
 t/config.t                | 5 +++++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/lib/PublicInbox/Config.pm b/lib/PublicInbox/Config.pm
index 34abcea3..4065b256 100644
--- a/lib/PublicInbox/Config.pm
+++ b/lib/PublicInbox/Config.pm
@@ -580,6 +580,7 @@ sub squote_maybe ($) {
 }
 
 my %re_map = ( '*' => '[^/]*?', '?' => '[^/]',
+		'/**' => '/.*', '**/' => '.*/', '/**/' => '/.*?',
 		'[' => '[', ']' => ']', ',' => ',' );
 
 sub glob2re ($) {
@@ -593,7 +594,7 @@ sub glob2re ($) {
 	if ($re =~ s!\A([a-z0-9\+]+://\[[a-f0-9\:]+\](?::[0-9]+)?/)!!i) {
 		$schema_host_port = quotemeta $1; # "http://[::1]:1234"
 	}
-	my $changes = ($re =~ s!(.)!
+	my $changes = ($re =~ s!(/\*\*/|\A\*\*/|/\*\*\z|.)!
 		$re_map{$p eq '\\' ? '' : do {
 			if ($1 eq '[') { ++$in_bracket }
 			elsif ($1 eq ']') { --$in_bracket }
diff --git a/t/config.t b/t/config.t
index d67931da..80f214cd 100644
--- a/t/config.t
+++ b/t/config.t
@@ -274,5 +274,10 @@ is_deeply($glob2re->('*.[ch]'), '[^/]*?\\.[ch]', 'suffix glob');
 is_deeply($glob2re->('{[a-z],9,}'), '([a-z]|9|)' , 'brace with range');
 is_deeply($glob2re->('\\{a,b\\}'), undef, 'escaped brace');
 is_deeply($glob2re->('\\\\{a,b}'), '\\\\\\\\(a|b)', 'fake escape brace');
+is_deeply($glob2re->('**/foo'), '.*/foo', 'double asterisk start');
+is_deeply($glob2re->('foo/**'), 'foo/.*', 'double asterisk end');
+my $re = $glob2re->('a/**/b');
+is_deeply($re, 'a/.*?b', 'double asterisk middle');
+like($_, qr!$re!, "a/**/b matches $_") for ('a/b', 'a/c/b', 'a/c/a/b');
 
 done_testing();

^ permalink raw reply related	[relevance 7%]

* [PATCH 0/2] globbing updates
@ 2023-03-17 20:31  5% Eric Wong
  2023-03-17 20:31  7% ` [PATCH 2/2] config: glob2re supports `**' to match multiple path components Eric Wong
  0 siblings, 1 reply; 2+ results
From: Eric Wong @ 2023-03-17 20:31 UTC (permalink / raw)
  To: meta

The code indexer will be using this to implement --exclude= when
combined with --project-list=, at least (because indexing
certain `code'repos takes forever).

Eric Wong (2):
  treewide: move glob2re to PublicInbox::Config
  config: glob2re supports `**' to match multiple path components

 lib/PublicInbox/Config.pm        | 35 +++++++++++++++++++++++++++++++
 lib/PublicInbox/LeiExternal.pm   | 36 +-------------------------------
 lib/PublicInbox/LeiLsExternal.pm |  3 ++-
 lib/PublicInbox/LeiLsMailSync.pm |  3 ++-
 lib/PublicInbox/LeiMirror.pm     |  6 +++---
 t/config.t                       | 23 ++++++++++++++++++--
 t/lei_external.t                 | 20 ++----------------
 7 files changed, 66 insertions(+), 60 deletions(-)

^ permalink raw reply	[relevance 5%]

Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2023-03-17 20:31  5% [PATCH 0/2] globbing updates Eric Wong
2023-03-17 20:31  7% ` [PATCH 2/2] config: glob2re supports `**' to match multiple path components Eric Wong

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