pub struct File<'a> { /* private fields */ }
Expand description
Represents a .gitignore
file. Use this to load the .gitignore
file, parse the patterns,
and then check if a given path would be excluded by any rules contained therein.
Examples
let file = gitignore::File::new(&gitignore_path).unwrap();
assert!(file.is_excluded(&path_to_test_if_excluded).unwrap())
Implementations§
source§impl<'b> File<'b>
impl<'b> File<'b>
sourcepub fn new(gitignore_path: &'b Path) -> Result<File<'b>, Error>
pub fn new(gitignore_path: &'b Path) -> Result<File<'b>, Error>
Parse the given .gitignore
file for patterns, allowing any arbitrary path to be checked
against the set of rules to test for exclusion.
The value of gitignore_path
must be an absolute path.
sourcepub fn is_excluded(&self, path: &'b Path) -> Result<bool, Error>
pub fn is_excluded(&self, path: &'b Path) -> Result<bool, Error>
Returns true if, after checking against all the patterns found in the .gitignore
file,
the given path is matched any of the globs (applying negated patterns as expected). Note
this function also returns false if the path does not exist.
If the value for path
is not absolute, it will assumed to be relative to the current
working directory.