Expand description
Parse path specifications and see if a path matches.
§Examples
use std::path::Path;
fn no_attrs(
_path: &bstr::BStr,
_case: gix_pathspec::attributes::glob::pattern::Case,
_is_dir: bool,
_out: &mut gix_pathspec::attributes::search::Outcome,
) -> bool {
false
}
let specs = ["src/**", ":!src/generated/**"]
.into_iter()
.map(|spec| gix_pathspec::parse(spec.as_bytes(), Default::default()).unwrap());
let mut search = gix_pathspec::Search::from_specs(specs, None, Path::new(""))?;
assert!(search.can_match_relative_path("src".into(), Some(true)));
let matched = search
.pattern_matching_relative_path("src/lib.rs".into(), Some(false), &mut no_attrs)
.unwrap();
assert_eq!(matched.pattern.path(), "src/**");
assert!(!matched.pattern.is_excluded());
let excluded = search
.pattern_matching_relative_path("src/generated/lib.rs".into(), Some(false), &mut no_attrs)
.unwrap();
assert_eq!(excluded.pattern.to_bstring(), ":(exclude)src/generated/**");
assert!(excluded.pattern.is_excluded());Re-exports§
pub use gix_attributes as attributes;
Modules§
Structs§
- Defaults
- Default settings for some fields of a
Pattern. - Magic
Signature - Flags to represent ‘magic signatures’ which are parsed behind colons, like
:top:. - Pattern
- The output of a pathspec parsing operation. It can be used to match against a one or more paths.
- Search
- A lists of pathspec patterns, possibly from a file.
Enums§
- Search
Mode - Parts of magic signatures which don’t stack as they all configure the way path specs are matched.