Struct GitignoreBuilder
struct GitignoreBuilder { ... }
Builds a matcher for a single set of globs from a .gitignore file.
Implementations
impl GitignoreBuilder
fn new<P: AsRef<Path>>(root: P) -> GitignoreBuilderCreate a new builder for a gitignore file.
The path given should be the path at which the globs for this gitignore file should be matched. Note that paths are always matched relative to the root path given here. Generally, the root path should correspond to the directory containing a
.gitignorefile.fn build(self: &Self) -> Result<Gitignore, Error>Builds a new matcher from the globs added so far.
Once a matcher is built, no new globs can be added to it.
fn build_global(self: Self) -> (Gitignore, Option<Error>)Build a global gitignore matcher using the configuration in this builder.
This consumes ownership of the builder unlike
buildbecause it must mutate the builder to add the global gitignore globs.Note that this ignores the path given to this builder's constructor and instead derives the path automatically from git's global configuration.
fn add<P: AsRef<Path>>(self: &mut Self, path: P) -> Option<Error>Add each glob from the file path given.
The file given should be formatted as a
gitignorefile.Note that partial errors can be returned. For example, if there was a problem adding one glob, an error for that will be returned, but all other valid globs will still be added.
fn add_line(self: &mut Self, from: Option<PathBuf>, line: &str) -> Result<&mut GitignoreBuilder, Error>Add a line from a gitignore file to this builder.
If this line came from a particular
gitignorefile, then its path should be provided here.If the line could not be parsed as a glob, then an error is returned.
fn case_insensitive(self: &mut Self, yes: bool) -> Result<&mut GitignoreBuilder, Error>Toggle whether the globs should be matched case insensitively or not.
When this option is changed, only globs added after the change will be affected.
This is disabled by default.
fn allow_unclosed_class(self: &mut Self, yes: bool) -> &mut GitignoreBuilderToggle whether unclosed character classes are allowed. When allowed, a
[without a matching]is treated literally instead of resulting in a parse error.For example, if this is set then the glob
[abcwill be treated as the literal string[abcinstead of returning an error.By default, this is true in order to match established
gitignoresemantics. Generally speaking, enabling this leads to worse failure modes since the glob parser becomes more permissive. You might want to enable this when compatibility (e.g., with POSIX glob implementations) is more important than good error messages.
impl Clone for GitignoreBuilder
fn clone(self: &Self) -> GitignoreBuilder
impl Debug for GitignoreBuilder
fn fmt(self: &Self, f: &mut $crate::fmt::Formatter<'_>) -> $crate::fmt::Result
impl Freeze for GitignoreBuilder
impl RefUnwindSafe for GitignoreBuilder
impl Send for GitignoreBuilder
impl Sync for GitignoreBuilder
impl Unpin for GitignoreBuilder
impl UnwindSafe for GitignoreBuilder
impl<T> Any for GitignoreBuilder
fn type_id(self: &Self) -> TypeId
impl<T> Borrow for GitignoreBuilder
fn borrow(self: &Self) -> &T
impl<T> BorrowMut for GitignoreBuilder
fn borrow_mut(self: &mut Self) -> &mut T
impl<T> CloneToUninit for GitignoreBuilder
unsafe fn clone_to_uninit(self: &Self, dest: *mut u8)
impl<T> From for GitignoreBuilder
fn from(t: T) -> TReturns the argument unchanged.
impl<T> Pointable for GitignoreBuilder
unsafe fn init(init: <T as Pointable>::Init) -> usizeunsafe fn deref<'a>(ptr: usize) -> &'a Tunsafe fn deref_mut<'a>(ptr: usize) -> &'a mut Tunsafe fn drop(ptr: usize)
impl<T> ToOwned for GitignoreBuilder
fn to_owned(self: &Self) -> Tfn clone_into(self: &Self, target: &mut T)
impl<T, U> Into for GitignoreBuilder
fn into(self: Self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom for GitignoreBuilder
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto for GitignoreBuilder
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>