Skip to content

Commit

Permalink
Switch to hash-based filtering of directories
Browse files Browse the repository at this point in the history
And remove the ignore-bad-dir test; it's no longer relevant.
  • Loading branch information
hoelzro committed Dec 1, 2011
1 parent f57fc3c commit 0337281
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 32 deletions.
26 changes: 13 additions & 13 deletions ack-base
Original file line number Diff line number Diff line change
Expand Up @@ -55,24 +55,24 @@ sub _compile_descend_filter {
my $idirs = $opt->{idirs};
return unless $idirs && @{$idirs};

my @idirs_filters = map {
my $filter;
my %ignore_dirs;

if($_ =~ /^(\w+),(.*)/) {
$filter = App::Ack::Filter->create_filter($1, split(/,/, $2));
} else {
foreach my $idir (@{$idirs}) {
if( $idir =~ /^(\w+),(.*)/ ) {
if( $1 eq 'is') {
$ignore_dirs{$2} = 1;
}
else {
Carp::croak "Non-is filters are not yet supported for --ignore-dir";
}
}
else {
Carp::croak "invalid filter specification '$_'";
}
$filter;
} @{$idirs};
}

return sub {
my $resource = App::Ack::Resource::Basic->new($File::Next::dir);
return unless $resource;
foreach my $filter (@idirs_filters) {
return 0 if $filter->filter($resource);
}
return 1;
return !exists $ignore_dirs{$_} && !exists $ignore_dirs{$File::Next::dir};
};
}

Expand Down
19 changes: 0 additions & 19 deletions t/ignore-bad-dir.t

This file was deleted.

0 comments on commit 0337281

Please sign in to comment.