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

Function reindex_working_copy

atomic-cli/src/commands/git/import.rs:709–739  ·  view source on GitHub ↗

Rebuild FILE_INDEX from the current working copy. During normal single-branch Git import the files on disk are already the authoritative Git checkout for the imported branch, so there is no reason to materialize the same content back out of Atomic. Indexing the tracked files makes the post-import `atomic status` baseline clean.

(repo: &Repository)

Source from the content-addressed store, hash-verified

707/// to materialize the same content back out of Atomic. Indexing the tracked
708/// files makes the post-import `atomic status` baseline clean.
709fn reindex_working_copy(repo: &Repository) {
710 use atomic_core::types::Hash;
711 use std::time::SystemTime;
712
713 let repo_root = repo.root().to_path_buf();
714 let tracked = repo.list_tracked_files().unwrap_or_default();
715 let mut entries: Vec<(String, i64, u32, u64, Hash)> = Vec::new();
716
717 for file in &tracked {
718 let abs = repo_root.join(&file.path);
719 if let Ok(metadata) = std::fs::metadata(&abs) {
720 let mtime = metadata.modified().unwrap_or(SystemTime::UNIX_EPOCH);
721 let duration = mtime
722 .duration_since(SystemTime::UNIX_EPOCH)
723 .unwrap_or_default();
724 if let Ok(bytes) = std::fs::read(&abs) {
725 entries.push((
726 file.path.to_string_lossy().replace('\\', "/"),
727 duration.as_secs() as i64,
728 duration.subsec_nanos(),
729 metadata.len(),
730 Hash::of(&bytes),
731 ));
732 }
733 }
734 }
735
736 if !entries.is_empty() {
737 let _ = repo.update_file_index(&entries);
738 }
739}
740
741/// Create .atomicignore and initialize vault AFTER git import + materialize.
742///

Callers 1

runMethod · 0.85

Calls 8

list_tracked_filesMethod · 0.80
rootMethod · 0.45
modifiedMethod · 0.45
pushMethod · 0.45
replaceMethod · 0.45
lenMethod · 0.45
is_emptyMethod · 0.45
update_file_indexMethod · 0.45

Tested by

no test coverage detected