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)
| 3790 | /// Scans all changes on the current view, looks for `unhashed.git.sha`, |
| 3791 | /// and populates the index. Idempotent — skips already-indexed SHAs. |
| 3792 | pub fn backfill_git_sha_index(&self) -> Result<usize, RepositoryError> { |
| 3793 | use crate::HistoryOptions; |
| 3794 | use atomic_core::pristine::GitShaIndexTxnT; |
| 3795 | |
| 3796 | let entries = self.log(HistoryOptions::default())?; |
| 3797 | let mut count = 0; |
| 3798 | |
| 3799 | for entry in &entries { |
| 3800 | if let Ok(change) = self.load_change(&entry.hash) { |
| 3801 | if let Some(ref unhashed) = change.unhashed { |
| 3802 | if let Some(git) = unhashed.get("git") { |
| 3803 | if let Some(sha) = git.get("sha").and_then(|v| v.as_str()) { |
| 3804 | // Check if already indexed |
| 3805 | { |
| 3806 | let txn = self |
| 3807 | .pristine |
| 3808 | .read_txn() |
| 3809 | .map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 3810 | if txn.has_git_sha(sha).unwrap_or(false) { |
| 3811 | continue; |
| 3812 | } |
| 3813 | } |
| 3814 | // Index it |
| 3815 | if let Err(e) = self.index_git_sha(sha, &entry.hash) { |
| 3816 | log::warn!( |
| 3817 | "Failed to index git SHA {}: {}", |
| 3818 | &sha[..8.min(sha.len())], |
| 3819 | e |
| 3820 | ); |
| 3821 | } else { |
| 3822 | count += 1; |
| 3823 | } |
| 3824 | } |
| 3825 | } |
| 3826 | } |
| 3827 | } |
| 3828 | } |
| 3829 | |
| 3830 | Ok(count) |
| 3831 | } |
| 3832 | } |
nothing calls this directly
no test coverage detected