1
0
mirror of https://github.com/BurntSushi/ripgrep.git synced 2024-12-12 19:18:24 +02:00
ripgrep/ignore
Andrew Gallant 361698b90a
ignore: fix improper hidden filtering
This commit fixes a bug where `rg --hidden .` would behave differently
with respect to ignore filtering than `rg --hidden ./`. In particular,
this was due to a bug where the directory name `.` caused the leading
`.` in a hidden directory to get stripped, which in turn caused the
ignore rules to fail.

Fixes #807
2018-02-14 18:16:38 -05:00
..
examples Add parallel recursive directory iterator. 2016-11-05 21:45:55 -04:00
src ignore: fix improper hidden filtering 2018-02-14 18:16:38 -05:00
tests ignore: fix handling of / in patterns 2018-01-29 14:10:59 -05:00
Cargo.toml ignore: release 0.4.0 2018-02-11 13:42:59 -05:00
COPYING Add license files to each crate. 2017-03-12 16:57:15 -04:00
LICENSE-MIT Add license files to each crate. 2017-03-12 16:57:15 -04:00
README.md Bump Cargo.toml version in ReadMe from 0.2 to 0.3 2017-11-17 17:57:57 -05:00
UNLICENSE Add license files to each crate. 2017-03-12 16:57:15 -04:00

ignore

The ignore crate provides a fast recursive directory iterator that respects various filters such as globs, file types and .gitignore files. This crate also provides lower level direct access to gitignore and file type matchers.

Linux build status Windows build status

Dual-licensed under MIT or the UNLICENSE.

Documentation

https://docs.rs/ignore

Usage

Add this to your Cargo.toml:

[dependencies]
ignore = "0.3"

and this to your crate root:

extern crate ignore;

Example

This example shows the most basic usage of this crate. This code will recursively traverse the current directory while automatically filtering out files and directories according to ignore globs found in files like .ignore and .gitignore:

use ignore::Walk;

for result in Walk::new("./") {
    // Each item yielded by the iterator is either a directory entry or an
    // error, so either print the path or the error.
    match result {
        Ok(entry) => println!("{}", entry.path().display()),
        Err(err) => println!("ERROR: {}", err),
    }
}

Example: advanced

By default, the recursive directory iterator will ignore hidden files and directories. This can be disabled by building the iterator with WalkBuilder:

use ignore::WalkBuilder;

for result in WalkBuilder::new("./").hidden(false).build() {
    println!("{:?}", result);
}

See the documentation for WalkBuilder for many other options.