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

Method walk

atomic-repository/src/repository/switch.rs:396–433  ·  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

394
395 // Recursive walker that stops descending into ignored directories.
396 fn walk(
397 root: &Path,
398 dir: &Path,
399 rules: &crate::ignore::IgnoreRules,
400 out: &mut Vec<String>,
401 ) {
402 let entries = match std::fs::read_dir(dir) {
403 Ok(e) => e,
404 Err(_) => return,
405 };
406 for entry in entries.flatten() {
407 let abs = entry.path();
408 let rel = match abs.strip_prefix(root) {
409 Ok(r) => r,
410 Err(_) => continue,
411 };
412
413 // Never touch VCS administrative directories. `.git` can be
414 // ignored by `.atomicignore` after `atomic git import`, but
415 // it remains owned by Git rather than a view workspace.
416 if rel.starts_with(DOT_DIR) || rel.starts_with(".git") {
417 continue;
418 }
419
420 let is_dir = abs.is_dir();
421
422 if rules.is_ignored(rel, is_dir) {
423 // Collect the top-level ignored entry — don't recurse.
424 if let Some(s) = rel.to_str() {
425 out.push(s.to_string());
426 }
427 } else if is_dir {
428 // Not ignored — recurse to find ignored children.
429 walk(root, &abs, rules, out);
430 }
431 // Non-ignored files are left alone.
432 }
433 }
434
435 walk(&self.root, &self.root, &rules, &mut result);
436 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

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

Tested by

no test coverage detected