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)
| 3868 | /// Scans all changes on the current view, looks for `unhashed.git.sha`, |
| 3869 | /// and populates the index. Idempotent — skips already-indexed SHAs. |
| 3870 | pub fn backfill_git_sha_index(&self) -> Result<usize, RepositoryError> { |
| 3871 | use crate::HistoryOptions; |
| 3872 | use atomic_core::pristine::GitShaIndexTxnT; |
| 3873 | |
| 3874 | let entries = self.log(HistoryOptions::default())?; |
| 3875 | let mut count = 0; |
| 3876 | |
| 3877 | for entry in &entries { |
| 3878 | if let Ok(change) = self.load_change(&entry.hash) { |
| 3879 | if let Some(ref unhashed) = change.unhashed { |
| 3880 | if let Some(git) = unhashed.get("git") { |
| 3881 | if let Some(sha) = git.get("sha").and_then(|v| v.as_str()) { |
| 3882 | // Check if already indexed |
| 3883 | { |
| 3884 | let txn = self |
| 3885 | .pristine |
| 3886 | .read_txn() |
| 3887 | .map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 3888 | if txn.has_git_sha(sha).unwrap_or(false) { |
| 3889 | continue; |
| 3890 | } |
| 3891 | } |
| 3892 | // Index it |
| 3893 | if let Err(e) = self.index_git_sha(sha, &entry.hash) { |
| 3894 | log::warn!( |
| 3895 | "Failed to index git SHA {}: {}", |
| 3896 | &sha[..8.min(sha.len())], |
| 3897 | e |
| 3898 | ); |
| 3899 | } else { |
| 3900 | count += 1; |
| 3901 | } |
| 3902 | } |
| 3903 | } |
| 3904 | } |
| 3905 | } |
| 3906 | } |
| 3907 | |
| 3908 | Ok(count) |
| 3909 | } |
| 3910 | } |
nothing calls this directly
no test coverage detected