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

Function current_heads

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

Source from the content-addressed store, hash-verified

2800}
2801
2802pub(crate) fn current_heads(
2803 repo: &Repository,
2804 working_copy: WorkingCopyId,
2805 git: &GitRepository,
2806) -> CliResult<ShimSnapshot> {
2807 let head = git
2808 .head()
2809 .map_err(|error| git_error(format!("Git HEAD is unavailable: {error}")))?;
2810 let oid = head
2811 .target()
2812 .ok_or_else(|| git_error("Git HEAD does not point directly to a commit"))?;
2813 let tree = head
2814 .peel_to_commit()
2815 .and_then(|commit| commit.tree())
2816 .map_err(|error| git_error(format!("cannot read Git HEAD tree: {error}")))?;
2817 let view = repo
2818 .desired_view_name(working_copy)
2819 .map_err(CliError::from)?;
2820 let atomic_state = repo
2821 .get_view_info(&view)
2822 .map_err(CliError::from)?
2823 .state
2824 .to_string();
2825 Ok(ShimSnapshot {
2826 view,
2827 atomic_state,
2828 git_head: oid.to_string(),
2829 git_tree: tree.id().to_string(),
2830 })
2831}
2832
2833pub(crate) fn read_checkpoint_observation(
2834 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