MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / walk

Method walk

atomic-repository/src/repository/switch.rs:379–414  ·  view source on GitHub ↗

Recursive walker that stops descending into ignored directories.

(
            root: &Path,
            dir: &Path,
            rules: &crate::ignore::IgnoreRules,
            out: &mut Vec<String>,
        )

Source from the content-addressed store, hash-verified

377
378 // Recursive walker that stops descending into ignored directories.
379 fn walk(
380 root: &Path,
381 dir: &Path,
382 rules: &crate::ignore::IgnoreRules,
383 out: &mut Vec<String>,
384 ) {
385 let entries = match std::fs::read_dir(dir) {
386 Ok(e) => e,
387 Err(_) => return,
388 };
389 for entry in entries.flatten() {
390 let abs = entry.path();
391 let rel = match abs.strip_prefix(root) {
392 Ok(r) => r,
393 Err(_) => continue,
394 };
395
396 // Never touch the .atomic directory itself.
397 if rel.starts_with(DOT_DIR) {
398 continue;
399 }
400
401 let is_dir = abs.is_dir();
402
403 if rules.is_ignored(rel, is_dir) {
404 // Collect the top-level ignored entry — don't recurse.
405 if let Some(s) = rel.to_str() {
406 out.push(s.to_string());
407 }
408 } else if is_dir {
409 // Not ignored — recurse to find ignored children.
410 walk(root, &abs, rules, out);
411 }
412 // Non-ignored files are left alone.
413 }
414 }
415
416 walk(&self.root, &self.root, &rules, &mut result);
417 result

Callers 15

walk_treeMethod · 0.80
extract_functionMethod · 0.80
extract_impl_nameMethod · 0.80
is_pubMethod · 0.80
walk_tree_for_callsMethod · 0.80
walk_treeMethod · 0.80
extract_fieldsMethod · 0.80
has_modifierMethod · 0.80
walk_tree_for_callsMethod · 0.80

Calls 5

walkFunction · 0.85
is_dirMethod · 0.80
pathMethod · 0.45
is_ignoredMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected