Record missing Git SHA → Atomic change mappings in one transaction. Existing mappings are skipped. If every mapping is already indexed the write transaction is dropped without committing, keeping incremental no-op imports free of per-change database writes.
(&self, mappings: &[(String, Hash)])
| 2707 | /// write transaction is dropped without committing, keeping incremental |
| 2708 | /// no-op imports free of per-change database writes. |
| 2709 | pub fn index_git_shas(&self, mappings: &[(String, Hash)]) -> Result<usize, RepositoryError> { |
| 2710 | use atomic_core::pristine::{GitShaIndexMutTxnT, GitShaIndexTxnT}; |
| 2711 | |
| 2712 | if mappings.is_empty() { |
| 2713 | return Ok(0); |
| 2714 | } |
| 2715 | |
| 2716 | let mut txn = self |
| 2717 | .pristine |
| 2718 | .write_txn() |
| 2719 | .map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 2720 | let mut inserted = 0; |
| 2721 | |
| 2722 | for (git_sha, change_hash) in mappings { |
| 2723 | if txn |
| 2724 | .has_git_sha(git_sha) |
| 2725 | .map_err(|e| RepositoryError::Database(e.to_string()))? |
| 2726 | { |
| 2727 | continue; |
| 2728 | } |
| 2729 | |
| 2730 | let entity_id = txn |
| 2731 | .get_internal(change_hash) |
| 2732 | .map_err(|e| RepositoryError::Database(e.to_string()))? |
| 2733 | .ok_or_else(|| { |
| 2734 | RepositoryError::Database(format!( |
| 2735 | "Change hash not found in INTERNAL: {}", |
| 2736 | change_hash.to_base32() |
| 2737 | )) |
| 2738 | })?; |
| 2739 | txn.put_git_sha(git_sha, entity_id) |
| 2740 | .map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 2741 | inserted += 1; |
| 2742 | } |
| 2743 | |
| 2744 | if inserted == 0 { |
| 2745 | return Ok(0); |
| 2746 | } |
| 2747 | |
| 2748 | txn.commit() |
| 2749 | .map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 2750 | Ok(inserted) |
| 2751 | } |
| 2752 | |
| 2753 | /// Check if a Git SHA has been indexed. |
| 2754 | pub fn has_git_sha(&self, git_sha: &str) -> Result<bool, RepositoryError> { |
no test coverage detected