]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
cindex: implement --exclude= like -clone
authorEric Wong <e@80x24.org>
Tue, 21 Mar 2023 23:07:27 +0000 (23:07 +0000)
committerEric Wong <e@80x24.org>
Sat, 25 Mar 2023 09:37:49 +0000 (09:37 +0000)
This is to ensure we can exclude certain repos which are
expensive-to-index (e.g. `**/deps.git', `**/transparency-logs/**').

lib/PublicInbox/CodeSearchIdx.pm
script/public-inbox-cindex

index 587f0b8188df266a5eeeb956b26e080b7fba925f..97c563bd2cbed9cec4e38344a655689d38e9b75e 100644 (file)
@@ -27,7 +27,7 @@ use File::Spec ();
 use PublicInbox::SHA qw(sha256_hex);
 use PublicInbox::Search qw(xap_terms);
 use PublicInbox::SearchIdx qw(add_val);
-use PublicInbox::Config;
+use PublicInbox::Config qw(glob2re);
 use PublicInbox::Spawn qw(spawn popen_rd);
 use PublicInbox::OnDestroy;
 use Socket qw(MSG_EOR);
@@ -566,6 +566,14 @@ sub cidx_run { # main entry point
                }
                warn "E: canonicalized and attempting to continue\n";
        }
+       if (defined(my $excl = $self->{-opt}->{exclude})) {
+               my $re = '(?:'.join('\\z|', map {
+                               glob2re($_) // qr/\A\Q$_\E/
+                       } @$excl).'\\z)';
+               @{$self->{git_dirs}} = grep {
+                       $_ =~ /$re/ ? (warn("# excluding $_\n"), 0) : 1;
+               } @{$self->{git_dirs}};
+       }
        local $self->{nchange} = 0;
        local $LIVE_JOBS = $self->{-opt}->{jobs} ||
                        PublicInbox::IPC::detect_nproc() || 2;
index 166c826145521455511c744954b23b74b5ad902a..420ef4dee75d56621b7ea300c7d7b846f33bf11d 100755 (executable)
@@ -26,7 +26,7 @@ EOF
 my $opt = { fsync => 1, scan => 1 }; # --no-scan is hidden
 GetOptions($opt, qw(quiet|q verbose|v+ reindex jobs|j=i fsync|sync! dangerous
                indexlevel|index-level|L=s batch_size|batch-size=s
-               project-list=s
+               project-list=s exclude=s@
                d=s update|u scan! prune dry-run|n C=s@ help|h))
        or die $help;
 if ($opt->{help}) { print $help; exit 0 };