pub struct IgnoreRules { /* private fields */ }Expand description
The patterns of a .dockerignore file, applied the way Docker applies them.
Each line is trimmed; a line starting with # is a comment and a blank line is skipped;
! makes an exception. The pattern is cleaned as Go’s filepath.Clean cleans it and a
leading / is dropped, so /foo, ./foo and foo/ all mean foo. A pattern matches a
path when it matches the path itself or any of its parent directories, so node_modules
excludes everything under it; the last line that matches decides, so a later ! line
re-includes.
The glob is Go’s filepath.Match plus **: * and ? stop at /, [...] is a
character class negated by ^ (not !, which is a member), \ escapes the next
character, **/ matches any number of directories including none, and a trailing **
matches anything. These are the semantics of moby’s patternmatcher, which
crates/microvms-core/tests/context_fuzz.rs checks against a rebuilt copy of its regex
translation.
Implementations§
Source§impl IgnoreRules
impl IgnoreRules
Sourcepub fn parse(text: &str) -> Result<IgnoreRules, Error>
pub fn parse(text: &str) -> Result<IgnoreRules, Error>
Parses a .dockerignore file’s text, refusing a line Docker would refuse: a bare
!, an unterminated [, or a class range that runs backwards.
Sourcepub fn excludes(&self, path: &str) -> bool
pub fn excludes(&self, path: &str) -> bool
Whether path — relative to the context root, /-separated — is excluded.
Sourcepub fn has_exceptions(&self) -> bool
pub fn has_exceptions(&self) -> bool
Whether any rule is an exception (!pattern), which is when an excluded directory
still has to be walked: an exception could bring something under it back.
Trait Implementations§
Source§impl Clone for IgnoreRules
impl Clone for IgnoreRules
Source§fn clone(&self) -> IgnoreRules
fn clone(&self) -> IgnoreRules
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for IgnoreRules
impl Debug for IgnoreRules
Source§impl Default for IgnoreRules
impl Default for IgnoreRules
Source§fn default() -> IgnoreRules
fn default() -> IgnoreRules
Auto Trait Implementations§
impl Freeze for IgnoreRules
impl RefUnwindSafe for IgnoreRules
impl Send for IgnoreRules
impl Sync for IgnoreRules
impl Unpin for IgnoreRules
impl UnsafeUnpin 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