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

Method index_git_sha

atomic-repository/src/repository/insert.rs:2581–2607  ·  view source on GitHub ↗

Record a Git SHA → Atomic change mapping in the GIT_SHA_INDEX. Called after each commit is imported to enable O(1) incremental lookups. The `change_hash` is the Atomic Blake3 hash returned by write_import_*.

(&self, git_sha: &str, change_hash: &Hash)

Source from the content-addressed store, hash-verified

2579 /// Called after each commit is imported to enable O(1) incremental lookups.
2580 /// The `change_hash` is the Atomic Blake3 hash returned by write_import_*.
2581 pub fn index_git_sha(&self, git_sha: &str, change_hash: &Hash) -> Result<(), RepositoryError> {
2582 use atomic_core::pristine::GitShaIndexMutTxnT;
2583
2584 let mut txn = self
2585 .pristine
2586 .write_txn()
2587 .map_err(|e| RepositoryError::Database(e.to_string()))?;
2588
2589 // Get the entity_id for this change hash
2590 let entity_id = txn
2591 .get_internal(change_hash)
2592 .map_err(|e| RepositoryError::Database(e.to_string()))?
2593 .ok_or_else(|| {
2594 RepositoryError::Database(format!(
2595 "Change hash not found in INTERNAL: {}",
2596 change_hash.to_base32()
2597 ))
2598 })?;
2599
2600 txn.put_git_sha(git_sha, entity_id)
2601 .map_err(|e| RepositoryError::Database(e.to_string()))?;
2602
2603 txn.commit()
2604 .map_err(|e| RepositoryError::Database(e.to_string()))?;
2605
2606 Ok(())
2607 }
2608
2609 /// Check if a Git SHA has been indexed.
2610 pub fn has_git_sha(&self, git_sha: &str) -> Result<bool, RepositoryError> {

Callers 3

write_commitMethod · 0.80
write_empty_commitMethod · 0.80

Calls 4

write_txnMethod · 0.80
put_git_shaMethod · 0.80
commitMethod · 0.80
get_internalMethod · 0.45

Tested by

no test coverage detected