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)
| 598 | /// to materialize the same content back out of Atomic. Indexing the tracked |
| 599 | /// files makes the post-import `atomic status` baseline clean. |
| 600 | fn reindex_working_copy(repo: &Repository) { |
| 601 | use atomic_core::types::Hash; |
| 602 | use std::time::SystemTime; |
| 603 | |
| 604 | let repo_root = repo.root().to_path_buf(); |
| 605 | let tracked = repo.list_tracked_files().unwrap_or_default(); |
| 606 | let mut entries: Vec<(String, i64, u32, u64, Hash)> = Vec::new(); |
| 607 | |
| 608 | for file in &tracked { |
| 609 | let abs = repo_root.join(&file.path); |
| 610 | if let Ok(metadata) = std::fs::metadata(&abs) { |
| 611 | let mtime = metadata.modified().unwrap_or(SystemTime::UNIX_EPOCH); |
| 612 | let duration = mtime |
| 613 | .duration_since(SystemTime::UNIX_EPOCH) |
| 614 | .unwrap_or_default(); |
| 615 | if let Ok(bytes) = std::fs::read(&abs) { |
| 616 | entries.push(( |
| 617 | file.path.to_string_lossy().replace('\\', "/"), |
| 618 | duration.as_secs() as i64, |
| 619 | duration.subsec_nanos(), |
| 620 | metadata.len(), |
| 621 | Hash::of(&bytes), |
| 622 | )); |
| 623 | } |
| 624 | } |
| 625 | } |
| 626 | |
| 627 | if !entries.is_empty() { |
| 628 | let _ = repo.update_file_index(&entries); |
| 629 | } |
| 630 | } |
| 631 | |
| 632 | /// Create .atomicignore and initialize vault AFTER git import + materialize. |
| 633 | /// |
no test coverage detected