(
&self,
source: Option<&Repository>,
branch_name: &str,
parsed: &ParsedCommit,
encoded_hashes: Option<&[String]>,
policy: &ConversionPolicy,
)
| 4610 | } |
| 4611 | |
| 4612 | fn verify_claimed_change_closure( |
| 4613 | &self, |
| 4614 | source: Option<&Repository>, |
| 4615 | branch_name: &str, |
| 4616 | parsed: &ParsedCommit, |
| 4617 | encoded_hashes: Option<&[String]>, |
| 4618 | policy: &ConversionPolicy, |
| 4619 | ) -> CliResult<()> { |
| 4620 | let source = source.ok_or_else(|| { |
| 4621 | git_error(format!( |
| 4622 | "commit {} claims Atomic provenance but no Atomic repository exists", |
| 4623 | parsed.git_sha |
| 4624 | )) |
| 4625 | })?; |
| 4626 | let encoded_hashes = encoded_hashes.ok_or_else(|| { |
| 4627 | git_error(format!( |
| 4628 | "commit {} claims Atomic state without an Atomic-Changes closure", |
| 4629 | parsed.git_sha |
| 4630 | )) |
| 4631 | })?; |
| 4632 | let hashes = encoded_hashes |
| 4633 | .iter() |
| 4634 | .map(|encoded| { |
| 4635 | ContentHash::from_base32(encoded.as_bytes()).ok_or_else(|| { |
| 4636 | git_error(format!( |
| 4637 | "commit {} carries invalid Atomic-Changes value '{encoded}'", |
| 4638 | parsed.git_sha |
| 4639 | )) |
| 4640 | }) |
| 4641 | }) |
| 4642 | .collect::<CliResult<Vec<_>>>()?; |
| 4643 | let expected = git_object_id(policy.object_format, parsed.tree_oid)?; |
| 4644 | let claim = self.resolve_view_claim(source, branch_name, parsed, &hashes)?; |
| 4645 | // A record projection names its exact view state next to the change |
| 4646 | // roots. The roots' dependency closure is NOT that state once the |
| 4647 | // view holds independent changes (a rename commuting with an earlier |
| 4648 | // edit of the same file), so the projection at the named state is |
| 4649 | // the identity to verify whenever that state is present. This is the |
| 4650 | // path a Git branch created from an imported tip takes |
| 4651 | // (docs/shim-review-testing.md §9): its projection commits name the |
| 4652 | // originating view, not the new branch. |
| 4653 | let mut state_projection_failure = None; |
| 4654 | if let Some(state) = claim.state { |
| 4655 | match source.project_tree_at_state(&claim.view, state, policy) { |
| 4656 | Ok(projection) => { |
| 4657 | verify_prospective_equivalence(&projection, &expected).map_err(|error| { |
| 4658 | git_error(format!( |
| 4659 | "commit {} carries a forged Atomic state claim: {error}", |
| 4660 | parsed.git_sha |
| 4661 | )) |
| 4662 | })?; |
| 4663 | return Ok(()); |
| 4664 | } |
| 4665 | Err(error) => { |
| 4666 | trace_git_import(format!( |
| 4667 | "commit {} names state {state} on view '{}' that is not projectable \ |
| 4668 | ({error}); verifying its change closure instead", |
| 4669 | parsed.git_sha, claim.view |
no test coverage detected