pub struct FilterPath { /* private fields */ }Expand description
A filter (include or exclude) representing a repository-relative path.
Implementations§
Source§impl FilterPath
impl FilterPath
Sourcepub fn new(path_spec: &str, relative_to: &str) -> Result<Self>
pub fn new(path_spec: &str, relative_to: &str) -> Result<Self>
Creates a filter from a pathspec-like string and a relative path within the repository.
path_spec may be relative (../included.txt), absolute (:/included.txt),
excluded (:!excluded.txt or :^excluded.txt), or contain wildcards. * matches
zero or more characters in one path segment, ? matches one character in a segment,
and a segment consisting of ** matches zero or more path segments.
relative_to is relative to the repository root; an empty string means the root.
Sourcepub fn is_exclude(&self) -> bool
pub fn is_exclude(&self) -> bool
Gets whether this is an exclude filter.
Sourcepub fn is_include(&self) -> bool
pub fn is_include(&self) -> bool
Gets whether this is an include filter.
Sourcepub fn repo_relative_path(&self) -> &str
pub fn repo_relative_path(&self) -> &str
Gets the represented path relative to the repository root.
Directory separators are forward slashes.
Sourcepub fn is_relative(&self) -> bool
pub fn is_relative(&self) -> bool
Gets whether the original pathspec was parsed as relative.
Sourcepub fn has_wildcard(&self) -> bool
pub fn has_wildcard(&self) -> bool
Gets whether this filter contains wildcard characters.
Sourcepub fn excludes(&self, repo_relative_path: &str, ignore_case: bool) -> bool
pub fn excludes(&self, repo_relative_path: &str, ignore_case: bool) -> bool
Determines whether this excluding filter matches repo_relative_path.
Set ignore_case to the repository’s core.ignorecase value.
Sourcepub fn includes(&self, repo_relative_path: &str, ignore_case: bool) -> bool
pub fn includes(&self, repo_relative_path: &str, ignore_case: bool) -> bool
Determines whether this including filter matches repo_relative_path.
Set ignore_case to the repository’s core.ignorecase value.
Sourcepub fn includes_children(
&self,
repo_relative_path: &str,
ignore_case: bool,
) -> bool
pub fn includes_children( &self, repo_relative_path: &str, ignore_case: bool, ) -> bool
Determines whether this including filter may match children of
repo_relative_path.
Sourcepub fn to_path_spec(&self, repo_relative_base_directory: &str) -> Result<String>
pub fn to_path_spec(&self, repo_relative_base_directory: &str) -> Result<String>
Converts this filter to a pathspec.
repo_relative_base_directory is the repository-relative directory from which
relative pathspecs should be expressed. An empty string means the repository root.