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

Method walk

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

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