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

Method walk

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

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