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

Function add_vault_files_recursive

atomic-cli/src/commands/init.rs:639–654  ·  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

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

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