(
repo: &git2::Repository,
object: &GitObjectId,
)
| 4730 | } |
| 4731 | |
| 4732 | pub(super) fn git_oid_from_object( |
| 4733 | repo: &git2::Repository, |
| 4734 | object: &GitObjectId, |
| 4735 | ) -> Result<git2::Oid, RepositoryError> { |
| 4736 | let hex = git_object_hex(object)?; |
| 4737 | let oid = git2::Oid::from_str(&hex).map_err(|error| RepositoryError::InvalidRepository { |
| 4738 | reason: format!("cannot parse Git object id '{hex}': {error}"), |
| 4739 | })?; |
| 4740 | let expected_width = match object.algorithm() { |
| 4741 | GitHashAlgorithm::Sha1 => 20, |
| 4742 | GitHashAlgorithm::Sha256 => 32, |
| 4743 | }; |
| 4744 | if oid.as_bytes().len() != expected_width { |
| 4745 | return Err(RepositoryError::InvalidRepository { |
| 4746 | reason: format!( |
| 4747 | "Git object id '{hex}' width {} disagrees with the repository format", |
| 4748 | oid.as_bytes().len() |
| 4749 | ), |
| 4750 | }); |
| 4751 | } |
| 4752 | let _ = repo; |
| 4753 | Ok(oid) |
| 4754 | } |
| 4755 | |
| 4756 | fn unsupported_effect_error(target: &EffectTarget) -> RepositoryError { |
| 4757 | RepositoryError::InvalidOperation { |
no test coverage detected