MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / observation_evidence

Function observation_evidence

atomic-cli/src/commands/git/hooks.rs:1748–1802  ·  view source on GitHub ↗
(observation: GitObservation)

Source from the content-addressed store, hash-verified

1746}
1747
1748fn observation_evidence(observation: GitObservation) -> GitObservationEvidence {
1749 match observation {
1750 GitObservation::NoGit { root } => GitObservationEvidence {
1751 git_present: false,
1752 worktree_root: Some(root),
1753 worktree_git_dir: None,
1754 common_dir: None,
1755 head_kind: None,
1756 head_symref: None,
1757 head_oid: None,
1758 head_tree_oid: None,
1759 index_tree_oid: None,
1760 index_digest: None,
1761 refs_digest: None,
1762 index_locked: false,
1763 ref_locks: Vec::new(),
1764 operation_state: None,
1765 operation_markers: Vec::new(),
1766 },
1767 GitObservation::Repository(repository) => {
1768 let (head_kind, head_symref, head_oid) = match &repository.head {
1769 HeadObservation::Attached { symref, oid } => {
1770 ("attached", Some(symref.clone()), Some(oid.to_string()))
1771 }
1772 HeadObservation::Detached { oid } => ("detached", None, Some(oid.to_string())),
1773 HeadObservation::Unborn { symref } => ("unborn", Some(symref.clone()), None),
1774 HeadObservation::MissingTarget { symref } => {
1775 ("missing-target", Some(symref.clone()), None)
1776 }
1777 };
1778 GitObservationEvidence {
1779 git_present: true,
1780 worktree_root: repository.paths.worktree_root.clone(),
1781 worktree_git_dir: Some(repository.paths.worktree_git_dir.clone()),
1782 common_dir: Some(repository.paths.common_dir.clone()),
1783 head_kind: Some(head_kind),
1784 head_symref,
1785 head_oid,
1786 head_tree_oid: repository.head_tree_oid.map(|oid| oid.to_string()),
1787 index_tree_oid: repository.index.tree_oid.map(|oid| oid.to_string()),
1788 index_digest: Some(repository.index.canonical_digest.0.clone()),
1789 refs_digest: Some(repository.refs_digest.0.clone()),
1790 index_locked: repository.locks.index_lock.is_present(),
1791 ref_locks: repository.locks.ref_locks.clone(),
1792 operation_state: Some(repository.operation.repository_state.clone()),
1793 operation_markers: repository
1794 .operation
1795 .present_markers()
1796 .into_iter()
1797 .map(|marker| marker.as_str())
1798 .collect(),
1799 }
1800 }
1801 }
1802}
1803
1804fn warn_if_view_mismatch(root: &Path) {
1805 let atomic_view = match fs::read_to_string(root.join(".atomic/current_view")) {

Callers 1

run_deferred_observationFunction · 0.85

Calls 6

cloneMethod · 0.45
is_presentMethod · 0.45
collectMethod · 0.45
into_iterMethod · 0.45
present_markersMethod · 0.45
as_strMethod · 0.45

Tested by

no test coverage detected