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

Method backfill_git_sha_index

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

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}

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