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)])
| 2762 | /// write transaction is dropped without committing, keeping incremental |
| 2763 | /// no-op imports free of per-change database writes. |
| 2764 | pub fn index_git_shas(&self, mappings: &[(String, Hash)]) -> Result<usize, RepositoryError> { |
| 2765 | use atomic_core::pristine::{GitShaIndexMutTxnT, GitShaIndexTxnT}; |
| 2766 | |
| 2767 | if mappings.is_empty() { |
| 2768 | return Ok(0); |
| 2769 | } |
| 2770 | |
| 2771 | let mut txn = self |
| 2772 | .pristine |
| 2773 | .write_txn() |
| 2774 | .map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 2775 | let mut inserted = 0; |
| 2776 | |
| 2777 | for (git_sha, change_hash) in mappings { |
| 2778 | if txn |
| 2779 | .has_git_sha(git_sha) |
| 2780 | .map_err(|e| RepositoryError::Database(e.to_string()))? |
| 2781 | { |
| 2782 | continue; |
| 2783 | } |
| 2784 | |
| 2785 | let entity_id = txn |
| 2786 | .get_internal(change_hash) |
| 2787 | .map_err(|e| RepositoryError::Database(e.to_string()))? |
| 2788 | .ok_or_else(|| { |
| 2789 | RepositoryError::Database(format!( |
| 2790 | "Change hash not found in INTERNAL: {}", |
| 2791 | change_hash.to_base32() |
| 2792 | )) |
| 2793 | })?; |
| 2794 | txn.put_git_sha(git_sha, entity_id) |
| 2795 | .map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 2796 | inserted += 1; |
| 2797 | } |
| 2798 | |
| 2799 | if inserted == 0 { |
| 2800 | return Ok(0); |
| 2801 | } |
| 2802 | |
| 2803 | txn.commit() |
| 2804 | .map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 2805 | Ok(inserted) |
| 2806 | } |
| 2807 | |
| 2808 | /// Check if a Git SHA has been indexed. |
| 2809 | pub fn has_git_sha(&self, git_sha: &str) -> Result<bool, RepositoryError> { |
no test coverage detected