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

Function current_heads

atomic-cli/src/commands/git/shim.rs:2758–2787  ·  view source on GitHub ↗
(
    repo: &Repository,
    working_copy: WorkingCopyId,
    git: &GitRepository,
)

Source from the content-addressed store, hash-verified

2756}
2757
2758pub(crate) fn current_heads(
2759 repo: &Repository,
2760 working_copy: WorkingCopyId,
2761 git: &GitRepository,
2762) -> CliResult<ShimSnapshot> {
2763 let head = git
2764 .head()
2765 .map_err(|error| git_error(format!("Git HEAD is unavailable: {error}")))?;
2766 let oid = head
2767 .target()
2768 .ok_or_else(|| git_error("Git HEAD does not point directly to a commit"))?;
2769 let tree = head
2770 .peel_to_commit()
2771 .and_then(|commit| commit.tree())
2772 .map_err(|error| git_error(format!("cannot read Git HEAD tree: {error}")))?;
2773 let view = repo
2774 .desired_view_name(working_copy)
2775 .map_err(CliError::from)?;
2776 let atomic_state = repo
2777 .get_view_info(&view)
2778 .map_err(CliError::from)?
2779 .state
2780 .to_string();
2781 Ok(ShimSnapshot {
2782 view,
2783 atomic_state,
2784 git_head: oid.to_string(),
2785 git_tree: tree.id().to_string(),
2786 })
2787}
2788
2789pub(crate) fn read_checkpoint_observation(
2790 root: &Path,

Callers 3

enable_anchor_innerFunction · 0.85
switch_transactionFunction · 0.85

Calls 6

treeMethod · 0.80
desired_view_nameMethod · 0.80
get_view_infoMethod · 0.80
git_errorFunction · 0.70
headMethod · 0.45
idMethod · 0.45

Tested by

no test coverage detected