pub struct IgnoreRules {
pub root: PathBuf,
pub ignore_filename: Option<String>,
pub ignore_patterns: Arc<RwLock<Vec<Pattern>>>,
pub whitelist_patterns: Arc<RwLock<Vec<Pattern>>>,
}
Expand description
Complete set of ignore rules for a directory and its child directories.
Fields§
§root: PathBuf
The root of the ignore rules. Typically this is the root directory of Git or Xvc repository.
ignore_filename: Option<String>
The name of the ignore file (e.g. .xvcignore
, .gitignore
) to be loaded for ignore rules.
ignore_patterns: Arc<RwLock<Vec<Pattern>>>
All ignore patterns collected from ignore files or specified in code.
whitelist_patterns: Arc<RwLock<Vec<Pattern>>>
All whitelist patterns collected from ignore files or specified in code
Implementations§
Source§impl IgnoreRules
impl IgnoreRules
Sourcepub fn empty(dir: &Path, ignore_filename: Option<&str>) -> IgnoreRules
pub fn empty(dir: &Path, ignore_filename: Option<&str>) -> IgnoreRules
An empty set of ignore rules that neither ignores nor whitelists any path.
Sourcepub fn from_global_patterns(
ignore_root: &Path,
ignore_filename: Option<&str>,
given: &str,
) -> IgnoreRules
pub fn from_global_patterns( ignore_root: &Path, ignore_filename: Option<&str>, given: &str, ) -> IgnoreRules
Constructs a new IgnoreRules
instance from a given set of global ignore patterns.
Sourcepub fn from_patterns(
ignore_root: &Path,
ignore_filename: Option<&str>,
patterns: Vec<Pattern>,
) -> IgnoreRules
pub fn from_patterns( ignore_root: &Path, ignore_filename: Option<&str>, patterns: Vec<Pattern>, ) -> IgnoreRules
Constructs a new IgnoreRules
instance from a vector of patterns and a root path.
This function separates the patterns into ignore patterns and whitelist patterns
based on their PatternEffect
. It then stores these patterns and the root path
in a new IgnoreRules
instance.
§Arguments
patterns
- A vector ofPattern
instances to be used for creating theIgnoreRules
.ignore_root
- A reference to the root path for the ignore rules.
§Returns
A new IgnoreRules
instance containing the given patterns and root path.
Sourcepub fn check(&self, path: &Path) -> MatchResult
pub fn check(&self, path: &Path) -> MatchResult
Checks if a given path matches any of the whitelist or ignore patterns.
The function first checks if the path matches any of the whitelist patterns.
If a match is found, it returns MatchResult::Whitelist
.
If the path does not match any of the whitelist patterns, the function then checks
if the path matches any of the ignore patterns. If a match is found, it returns
MatchResult::Ignore
.
If the path does not match any of the whitelist or ignore patterns, the function
returns MatchResult::NoMatch
.
§Arguments
path
- A reference to the path to check.
§Returns
MatchResult::Whitelist
if the path matches a whitelist pattern.MatchResult::Ignore
if the path matches an ignore pattern.MatchResult::NoMatch
if the path does not match any pattern.
Sourcepub fn merge_with(&self, other: &IgnoreRules) -> Result<(), Error>
pub fn merge_with(&self, other: &IgnoreRules) -> Result<(), Error>
Merges the ignore and whitelist patterns of another IgnoreRules
instance into this one.
This function locks the ignore and whitelist patterns of both IgnoreRules
instances,
drains the patterns from the other instance, and pushes them into this instance.
The other instance is left empty after this operation.
§Arguments
other
- A reference to the otherIgnoreRules
instance to merge with.
§Returns
Ok(())
if the merge operation was successful.Err
if the merge operation failed.
§Panics
This function will panic if the roots of the two IgnoreRules
instances are not equal.
Trait Implementations§
Source§impl Clone for IgnoreRules
impl Clone for IgnoreRules
Source§fn clone(&self) -> IgnoreRules
fn clone(&self) -> IgnoreRules
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreAuto Trait Implementations§
impl Freeze for IgnoreRules
impl RefUnwindSafe for IgnoreRules
impl Send for IgnoreRules
impl Sync for IgnoreRules
impl Unpin for IgnoreRules
impl UnwindSafe for IgnoreRules
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more