(
repository: &GitRepository,
head: &HeadObservation,
)
| 815 | } |
| 816 | |
| 817 | fn observe_head_tree( |
| 818 | repository: &GitRepository, |
| 819 | head: &HeadObservation, |
| 820 | ) -> Result<(Option<Oid>, Vec<TreeEntryObservation>), ObservationError> { |
| 821 | let Some(oid) = head.oid() else { |
| 822 | return Ok((None, Vec::new())); |
| 823 | }; |
| 824 | let commit = repository.find_commit(oid).map_err(|error| { |
| 825 | ObservationError::new(format!("cannot read Git HEAD commit {oid}: {error}")) |
| 826 | })?; |
| 827 | let tree = commit.tree().map_err(|error| { |
| 828 | ObservationError::new(format!("cannot read Git HEAD tree for {oid}: {error}")) |
| 829 | })?; |
| 830 | let tree_oid = tree.id(); |
| 831 | let mut entries = Vec::new(); |
| 832 | collect_tree_entries(repository, &tree, &[], &mut entries)?; |
| 833 | entries.sort_by(|left, right| left.path.cmp(&right.path)); |
| 834 | Ok((Some(tree_oid), entries)) |
| 835 | } |
| 836 | |
| 837 | #[derive(Clone, Debug, Eq, PartialEq)] |
| 838 | struct TreeEntryObservation { |
no test coverage detected