Struct gitignore::File
[−]
[src]
pub struct File<'a> { /* fields omitted */ }
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())
Methods
impl<'b> File<'b>
[src]
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.
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.
fn included_files(&self) -> Result<Vec<PathBuf>, Error>
Returns a list of files that are not excluded by the rules in the loaded
.gitignore
file. It recurses through all subdirectories and returns
everything that is not ignored.