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

Function add_vault_files_recursive

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

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

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