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)])
| 2656 | /// write transaction is dropped without committing, keeping incremental |
| 2657 | /// no-op imports free of per-change database writes. |
| 2658 | pub fn index_git_shas(&self, mappings: &[(String, Hash)]) -> Result<usize, RepositoryError> { |
| 2659 | use atomic_core::pristine::{GitShaIndexMutTxnT, GitShaIndexTxnT}; |
| 2660 | |
| 2661 | if mappings.is_empty() { |
| 2662 | return Ok(0); |
| 2663 | } |
| 2664 | |
| 2665 | let mut txn = self |
| 2666 | .pristine |
| 2667 | .write_txn() |
| 2668 | .map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 2669 | let mut inserted = 0; |
| 2670 | |
| 2671 | for (git_sha, change_hash) in mappings { |
| 2672 | if txn |
| 2673 | .has_git_sha(git_sha) |
| 2674 | .map_err(|e| RepositoryError::Database(e.to_string()))? |
| 2675 | { |
| 2676 | continue; |
| 2677 | } |
| 2678 | |
| 2679 | let entity_id = txn |
| 2680 | .get_internal(change_hash) |
| 2681 | .map_err(|e| RepositoryError::Database(e.to_string()))? |
| 2682 | .ok_or_else(|| { |
| 2683 | RepositoryError::Database(format!( |
| 2684 | "Change hash not found in INTERNAL: {}", |
| 2685 | change_hash.to_base32() |
| 2686 | )) |
| 2687 | })?; |
| 2688 | txn.put_git_sha(git_sha, entity_id) |
| 2689 | .map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 2690 | inserted += 1; |
| 2691 | } |
| 2692 | |
| 2693 | if inserted == 0 { |
| 2694 | return Ok(0); |
| 2695 | } |
| 2696 | |
| 2697 | txn.commit() |
| 2698 | .map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 2699 | Ok(inserted) |
| 2700 | } |
| 2701 | |
| 2702 | /// Check if a Git SHA has been indexed. |
| 2703 | pub fn has_git_sha(&self, git_sha: &str) -> Result<bool, RepositoryError> { |
no test coverage detected