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,
)
| 718 | /// change (CB-10B review R5: the deferred default-init vault recording runs |
| 719 | /// only after an --adopt-git exact resurrection when one applies). |
| 720 | fn 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. |
| 754 | fn add_vault_files_recursive(repo: &Repository, dir: &std::path::Path) -> CliResult<()> { |
no test coverage detected