use crate::config::Config;
use ignore::WalkBuilder;
use std::path::Path;
pub fn walk(cfg: &Config, start: &Path) -> WalkBuilder {
let mut b = WalkBuilder::new(start);
b.hidden(false).filter_entry(outside_nested(cfg));
b
}
pub fn walk_across(starts: &[std::path::PathBuf]) -> Option<WalkBuilder> {
let (first, rest) = starts.split_first()?;
let mut b = WalkBuilder::new(first);
for d in rest {
b.add(d);
}
b.hidden(false).require_git(false).filter_entry(|e| e.file_name() != ".git");
Some(b)
}
fn outside_nested(cfg: &Config) -> impl Fn(&ignore::DirEntry) -> bool + Send + Sync + 'static {
let root = cfg.spec_home.clone();
let owners = cfg.raw.owners.clone();
move |e| crate::paths::rel_of(&root, e.path()).is_none_or(|r| r.is_empty() || !owners.in_nested(&r))
}