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

Method backfill_git_sha_index

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

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}

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected