Backfill the GIT_SHA_INDEX from existing imported changes. Scans all changes on the current view, looks for `unhashed.git.sha`, and populates the index. Idempotent — skips already-indexed SHAs.
(&self)
| 2768 | /// Scans all changes on the current view, looks for `unhashed.git.sha`, |
| 2769 | /// and populates the index. Idempotent — skips already-indexed SHAs. |
| 2770 | pub fn backfill_git_sha_index(&self) -> Result<usize, RepositoryError> { |
| 2771 | use crate::HistoryOptions; |
| 2772 | use atomic_core::pristine::GitShaIndexTxnT; |
| 2773 | |
| 2774 | let entries = self.log(HistoryOptions::default())?; |
| 2775 | let mut count = 0; |
| 2776 | |
| 2777 | for entry in &entries { |
| 2778 | if let Ok(change) = self.load_change(&entry.hash) { |
| 2779 | if let Some(ref unhashed) = change.unhashed { |
| 2780 | if let Some(git) = unhashed.get("git") { |
| 2781 | if let Some(sha) = git.get("sha").and_then(|v| v.as_str()) { |
| 2782 | // Check if already indexed |
| 2783 | { |
| 2784 | let txn = self |
| 2785 | .pristine |
| 2786 | .read_txn() |
| 2787 | .map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 2788 | if txn.has_git_sha(sha).unwrap_or(false) { |
| 2789 | continue; |
| 2790 | } |
| 2791 | } |
| 2792 | // Index it |
| 2793 | if let Err(e) = self.index_git_sha(sha, &entry.hash) { |
| 2794 | log::warn!( |
| 2795 | "Failed to index git SHA {}: {}", |
| 2796 | &sha[..8.min(sha.len())], |
| 2797 | e |
| 2798 | ); |
| 2799 | } else { |
| 2800 | count += 1; |
| 2801 | } |
| 2802 | } |
| 2803 | } |
| 2804 | } |
| 2805 | } |
| 2806 | } |
| 2807 | |
| 2808 | Ok(count) |
| 2809 | } |
| 2810 | } |
nothing calls this directly
no test coverage detected