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

Method backfill_git_sha_index

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

2624 /// Scans all changes on the current view, looks for `unhashed.git.sha`,
2625 /// and populates the index. Idempotent — skips already-indexed SHAs.
2626 pub fn backfill_git_sha_index(&self) -> Result<usize, RepositoryError> {
2627 use crate::HistoryOptions;
2628 use atomic_core::pristine::GitShaIndexTxnT;
2629
2630 let entries = self.log(HistoryOptions::default())?;
2631 let mut count = 0;
2632
2633 for entry in &entries {
2634 if let Ok(change) = self.load_change(&entry.hash) {
2635 if let Some(ref unhashed) = change.unhashed {
2636 if let Some(git) = unhashed.get("git") {
2637 if let Some(sha) = git.get("sha").and_then(|v| v.as_str()) {
2638 // Check if already indexed
2639 {
2640 let txn = self
2641 .pristine
2642 .read_txn()
2643 .map_err(|e| RepositoryError::Database(e.to_string()))?;
2644 if txn.has_git_sha(sha).unwrap_or(false) {
2645 continue;
2646 }
2647 }
2648 // Index it
2649 if let Err(e) = self.index_git_sha(sha, &entry.hash) {
2650 log::warn!(
2651 "Failed to index git SHA {}: {}",
2652 &sha[..8.min(sha.len())],
2653 e
2654 );
2655 } else {
2656 count += 1;
2657 }
2658 }
2659 }
2660 }
2661 }
2662 }
2663
2664 Ok(count)
2665 }
2666}

Callers 1

get_imported_shasMethod · 0.80

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