MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / backfill_git_sha_index

Method backfill_git_sha_index

atomic-repository/src/repository/insert.rs:2825–2864  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

2823 /// Scans all changes on the current view, looks for `unhashed.git.sha`,
2824 /// and populates the index. Idempotent — skips already-indexed SHAs.
2825 pub fn backfill_git_sha_index(&self) -> Result<usize, RepositoryError> {
2826 use crate::HistoryOptions;
2827 use atomic_core::pristine::GitShaIndexTxnT;
2828
2829 let entries = self.log(HistoryOptions::default())?;
2830 let mut count = 0;
2831
2832 for entry in &entries {
2833 if let Ok(change) = self.load_change(&entry.hash) {
2834 if let Some(ref unhashed) = change.unhashed {
2835 if let Some(git) = unhashed.get("git") {
2836 if let Some(sha) = git.get("sha").and_then(|v| v.as_str()) {
2837 // Check if already indexed
2838 {
2839 let txn = self
2840 .pristine
2841 .read_txn()
2842 .map_err(|e| RepositoryError::Database(e.to_string()))?;
2843 if txn.has_git_sha(sha).unwrap_or(false) {
2844 continue;
2845 }
2846 }
2847 // Index it
2848 if let Err(e) = self.index_git_sha(sha, &entry.hash) {
2849 log::warn!(
2850 "Failed to index git SHA {}: {}",
2851 &sha[..8.min(sha.len())],
2852 e
2853 );
2854 } else {
2855 count += 1;
2856 }
2857 }
2858 }
2859 }
2860 }
2861 }
2862
2863 Ok(count)
2864 }
2865}

Callers

nothing calls this directly

Calls 7

logMethod · 0.80
read_txnMethod · 0.80
index_git_shaMethod · 0.80
getMethod · 0.65
load_changeMethod · 0.45
as_strMethod · 0.45
has_git_shaMethod · 0.45

Tested by

no test coverage detected