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)
| 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> { |
no test coverage detected