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

Function add_vault_files_recursive

atomic-cli/src/commands/init.rs:632–647  ·  view source on GitHub ↗

Recursively add all files under a directory to Atomic tracking.

(repo: &Repository, dir: &std::path::Path)

Source from the content-addressed store, hash-verified

630
631/// Recursively add all files under a directory to Atomic tracking.
632fn add_vault_files_recursive(repo: &Repository, dir: &std::path::Path) -> CliResult<()> {
633 let entries = std::fs::read_dir(dir).map_err(CliError::Io)?;
634 for entry in entries {
635 let entry = entry.map_err(CliError::Io)?;
636 let path = entry.path();
637 if path.is_dir() {
638 add_vault_files_recursive(repo, &path)?;
639 } else if path.is_file() {
640 if let Ok(rel) = path.strip_prefix(repo.root()) {
641 let rel_str = rel.to_string_lossy().replace('\\', "/");
642 let _ = repo.add(&rel_str, atomic_repository::TrackingOptions::default());
643 }
644 }
645 }
646 Ok(())
647}
648
649// Tests
650

Callers 1

runMethod · 0.70

Calls 6

is_dirMethod · 0.80
pathMethod · 0.45
is_fileMethod · 0.45
rootMethod · 0.45
replaceMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected