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

Method backfill_git_sha_index

atomic-repository/src/repository/insert.rs:2770–2809  ·  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

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}

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