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

Function add_vault_files_recursive

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

752
753/// Recursively add all files under a directory to Atomic tracking.
754fn add_vault_files_recursive(repo: &Repository, dir: &std::path::Path) -> CliResult<()> {
755 let working_copy = repo
756 .require_working_copy_id()
757 .map_err(CliError::Repository)?;
758 let entries = std::fs::read_dir(dir).map_err(CliError::Io)?;
759 for entry in entries {
760 let entry = entry.map_err(CliError::Io)?;
761 let path = entry.path();
762 if path.is_dir() {
763 add_vault_files_recursive(repo, &path)?;
764 } else if path.is_file() {
765 if let Ok(rel) = path.strip_prefix(repo.root()) {
766 let rel_str = rel.to_string_lossy().replace('\\', "/");
767 let _ = repo.add(
768 working_copy,
769 &rel_str,
770 atomic_repository::TrackingOptions::default(),
771 );
772 }
773 }
774 }
775 Ok(())
776}
777
778// Tests
779

Callers 1

record_vault_stateFunction · 0.70

Calls 7

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