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)
| 2717 | /// Scans all changes on the current view, looks for `unhashed.git.sha`, |
| 2718 | /// and populates the index. Idempotent — skips already-indexed SHAs. |
| 2719 | pub fn backfill_git_sha_index(&self) -> Result<usize, RepositoryError> { |
| 2720 | use crate::HistoryOptions; |
| 2721 | use atomic_core::pristine::GitShaIndexTxnT; |
| 2722 | |
| 2723 | let entries = self.log(HistoryOptions::default())?; |
| 2724 | let mut count = 0; |
| 2725 | |
| 2726 | for entry in &entries { |
| 2727 | if let Ok(change) = self.load_change(&entry.hash) { |
| 2728 | if let Some(ref unhashed) = change.unhashed { |
| 2729 | if let Some(git) = unhashed.get("git") { |
| 2730 | if let Some(sha) = git.get("sha").and_then(|v| v.as_str()) { |
| 2731 | // Check if already indexed |
| 2732 | { |
| 2733 | let txn = self |
| 2734 | .pristine |
| 2735 | .read_txn() |
| 2736 | .map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 2737 | if txn.has_git_sha(sha).unwrap_or(false) { |
| 2738 | continue; |
| 2739 | } |
| 2740 | } |
| 2741 | // Index it |
| 2742 | if let Err(e) = self.index_git_sha(sha, &entry.hash) { |
| 2743 | log::warn!( |
| 2744 | "Failed to index git SHA {}: {}", |
| 2745 | &sha[..8.min(sha.len())], |
| 2746 | e |
| 2747 | ); |
| 2748 | } else { |
| 2749 | count += 1; |
| 2750 | } |
| 2751 | } |
| 2752 | } |
| 2753 | } |
| 2754 | } |
| 2755 | } |
| 2756 | |
| 2757 | Ok(count) |
| 2758 | } |
| 2759 | } |
nothing calls this directly
no test coverage detected