(observation: GitObservation)
| 1715 | } |
| 1716 | |
| 1717 | fn observation_evidence(observation: GitObservation) -> GitObservationEvidence { |
| 1718 | match observation { |
| 1719 | GitObservation::NoGit { root } => GitObservationEvidence { |
| 1720 | git_present: false, |
| 1721 | worktree_root: Some(root), |
| 1722 | worktree_git_dir: None, |
| 1723 | common_dir: None, |
| 1724 | head_kind: None, |
| 1725 | head_symref: None, |
| 1726 | head_oid: None, |
| 1727 | head_tree_oid: None, |
| 1728 | index_tree_oid: None, |
| 1729 | index_digest: None, |
| 1730 | refs_digest: None, |
| 1731 | index_locked: false, |
| 1732 | ref_locks: Vec::new(), |
| 1733 | operation_state: None, |
| 1734 | operation_markers: Vec::new(), |
| 1735 | }, |
| 1736 | GitObservation::Repository(repository) => { |
| 1737 | let (head_kind, head_symref, head_oid) = match &repository.head { |
| 1738 | HeadObservation::Attached { symref, oid } => { |
| 1739 | ("attached", Some(symref.clone()), Some(oid.to_string())) |
| 1740 | } |
| 1741 | HeadObservation::Detached { oid } => ("detached", None, Some(oid.to_string())), |
| 1742 | HeadObservation::Unborn { symref } => ("unborn", Some(symref.clone()), None), |
| 1743 | HeadObservation::MissingTarget { symref } => { |
| 1744 | ("missing-target", Some(symref.clone()), None) |
| 1745 | } |
| 1746 | }; |
| 1747 | GitObservationEvidence { |
| 1748 | git_present: true, |
| 1749 | worktree_root: repository.paths.worktree_root.clone(), |
| 1750 | worktree_git_dir: Some(repository.paths.worktree_git_dir.clone()), |
| 1751 | common_dir: Some(repository.paths.common_dir.clone()), |
| 1752 | head_kind: Some(head_kind), |
| 1753 | head_symref, |
| 1754 | head_oid, |
| 1755 | head_tree_oid: repository.head_tree_oid.map(|oid| oid.to_string()), |
| 1756 | index_tree_oid: repository.index.tree_oid.map(|oid| oid.to_string()), |
| 1757 | index_digest: Some(repository.index.canonical_digest.0.clone()), |
| 1758 | refs_digest: Some(repository.refs_digest.0.clone()), |
| 1759 | index_locked: repository.locks.index_lock.is_present(), |
| 1760 | ref_locks: repository.locks.ref_locks.clone(), |
| 1761 | operation_state: Some(repository.operation.repository_state.clone()), |
| 1762 | operation_markers: repository |
| 1763 | .operation |
| 1764 | .present_markers() |
| 1765 | .into_iter() |
| 1766 | .map(|marker| marker.as_str()) |
| 1767 | .collect(), |
| 1768 | } |
| 1769 | } |
| 1770 | } |
| 1771 | } |
| 1772 | |
| 1773 | fn warn_if_view_mismatch(root: &Path) { |
| 1774 | let atomic_view = match fs::read_to_string(root.join(".atomic/current_view")) { |
no test coverage detected