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

Function record_vault_state

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

Create the vault, install defaults, track and record them as their own change (CB-10B review R5: the deferred default-init vault recording runs only after an --adopt-git exact resurrection when one applies).

(
    repo: &Repository,
    working_copy: atomic_core::WorkingCopyId,
)

Source from the content-addressed store, hash-verified

718/// change (CB-10B review R5: the deferred default-init vault recording runs
719/// only after an --adopt-git exact resurrection when one applies).
720fn record_vault_state(
721 repo: &Repository,
722 working_copy: atomic_core::WorkingCopyId,
723) -> CliResult<()> {
724 // Create vault tables + directory structure + default files
725 repo.init_vault().map_err(CliError::Repository)?;
726
727 println!("Initialized vault at {}", repo.vault_dir().display());
728
729 // Add all vault files to tracking
730 let vault_dir = repo.vault_dir();
731 if vault_dir.exists() {
732 add_vault_files_recursive(repo, &vault_dir)?;
733 }
734
735 // Record vault files as their own change
736 let header = atomic_core::change::ChangeHeader::new("Initialize vault");
737 let options = atomic_repository::RecordOptions::new()
738 .add_path(".vault")
739 .detect_raw_renames(false);
740 match repo.record(working_copy, header, options) {
741 Ok(outcome) => {
742 println!(
743 "Recorded vault defaults ({} files)",
744 outcome.stats().files_recorded
745 );
746 }
747 Err(atomic_repository::RecordError::NothingToRecord) => {}
748 Err(e) => log::warn!("Failed to record vault files: {}", e),
749 }
750 Ok(())
751}
752
753/// Recursively add all files under a directory to Atomic tracking.
754fn add_vault_files_recursive(repo: &Repository, dir: &std::path::Path) -> CliResult<()> {

Callers 1

runMethod · 0.85

Calls 7

vault_dirMethod · 0.80
detect_raw_renamesMethod · 0.80
init_vaultMethod · 0.45
existsMethod · 0.45
add_pathMethod · 0.45
recordMethod · 0.45

Tested by

no test coverage detected