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

Function reindex_working_copy

atomic-cli/src/commands/git/import.rs:625–655  ·  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

623/// to materialize the same content back out of Atomic. Indexing the tracked
624/// files makes the post-import `atomic status` baseline clean.
625fn reindex_working_copy(repo: &Repository) {
626 use atomic_core::types::Hash;
627 use std::time::SystemTime;
628
629 let repo_root = repo.root().to_path_buf();
630 let tracked = repo.list_tracked_files().unwrap_or_default();
631 let mut entries: Vec<(String, i64, u32, u64, Hash)> = Vec::new();
632
633 for file in &tracked {
634 let abs = repo_root.join(&file.path);
635 if let Ok(metadata) = std::fs::metadata(&abs) {
636 let mtime = metadata.modified().unwrap_or(SystemTime::UNIX_EPOCH);
637 let duration = mtime
638 .duration_since(SystemTime::UNIX_EPOCH)
639 .unwrap_or_default();
640 if let Ok(bytes) = std::fs::read(&abs) {
641 entries.push((
642 file.path.to_string_lossy().replace('\\', "/"),
643 duration.as_secs() as i64,
644 duration.subsec_nanos(),
645 metadata.len(),
646 Hash::of(&bytes),
647 ));
648 }
649 }
650 }
651
652 if !entries.is_empty() {
653 let _ = repo.update_file_index(&entries);
654 }
655}
656
657/// Create .atomicignore and initialize vault AFTER git import + materialize.
658///

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