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

Method backfill_git_sha_index

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

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}

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