This is an implementation of .gitignore
parsing and matching in Rust. Use this library if you want to check whether a given path would be excluded by a .gitignore
file.
It currently builds on both nighly and stable versions of Rust.
The crate is called gitignore
and you can it is available via crates.io:
toml
[dependencies]
gitignore = "x.y.z"
You can also use the Git version directory simply by depending on it via Cargo:
toml
[dependencies.gitignore]
git = "https://github.com/nathankleyn/gitignore.rs.git"
There are some useful bundled binaries which you can view to see how you might apply this library. The Rust docs are available to view as well.
A simple example is as follows:
```rust // Create a file let file = gitignore::file::File::new(&pathtogitignore).unwrap();
// This returns a bool as to whether the file matches a rule in the .gitignore file. file.is_excluded(&path).unwrap(); ```