Skip to content

Commit

Permalink
some cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
iesahin committed Dec 30, 2023
1 parent 568b017 commit b765cf2
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 48 deletions.
4 changes: 2 additions & 2 deletions core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ pub use error::Error;
pub use error::Result;

pub use util::file::{
all_paths_and_metadata, dir_includes, filter_paths_by_directory, glob_includes, glob_paths,
XvcPathMetadataMap, XvcPathMetadataProvider,
all_paths_and_metadata, dir_includes, glob_includes, glob_paths, XvcPathMetadataMap,
XvcPathMetadataProvider,
};

/// Channel size for [crossbeam_channel::bounded] used across the library.
Expand Down
18 changes: 0 additions & 18 deletions core/src/util/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,24 +307,6 @@ pub fn compiled_regex(pat: String) -> Result<Regex> {
Regex::new(&pat).map_err(|source| Error::RegexError { source })
}

/// Returns a subset of `pmm` ([XvcPathMetadataMap]) that are child paths of `directory`.
pub fn filter_paths_by_directory(
pmm: &XvcPathMetadataMap,
directory: &XvcPath,
) -> XvcPathMetadataMap {
let paths = pmm
.iter()
.filter_map(|(p, md)| {
if p.starts_with(directory) {
Some((p.clone(), *md))
} else {
None
}
})
.collect::<XvcPathMetadataMap>();
paths
}

/// Returns all _non-ignored_ paths described with `glob` under `root_dir`
#[cached(
type = "UnboundCache<String, XvcPathMetadataMap>",
Expand Down
28 changes: 0 additions & 28 deletions walker/src/ignore_rules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,32 +133,4 @@ impl IgnoreRules {

Ok(())
}

/// Creates a new IgnoreRules object with the specified list of [GlobPattern]s.
/// It returns [Error::GlobError] if there are malformed globs in any of the files.
pub fn new(root: &Path, patterns: Vec<GlobPattern>) -> Result<Self> {
let patterns: Vec<GlobPattern> = patterns.into_iter().unique().collect();
let (ignore_patterns, whitelist_patterns): (Vec<_>, Vec<_>) = patterns
.into_iter()
.partition(|p| matches!(p.effect, PatternEffect::Ignore));

let ignore_globs: Vec<Glob> = ignore_patterns.iter().map(|p| p.pattern.clone()).collect();

let ignore_set = build_globset(ignore_globs)?;

let whitelist_globs: Vec<Glob> = whitelist_patterns
.iter()
.map(|p| p.pattern.clone())
.collect();

let whitelist_set = build_globset(whitelist_globs)?;

Ok(IgnoreRules {
root: root.to_path_buf(),
ignore_patterns: Arc::new(RwLock::new(ignore_patterns)),
whitelist_patterns: Arc::new(RwLock::new(whitelist_patterns)),
whitelist_set: Arc::new(RwLock::new(whitelist_set)),
ignore_set: Arc::new(RwLock::new(ignore_set)),
})
}
}

0 comments on commit b765cf2

Please sign in to comment.