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

Function load_binding_at_ref

atomic-cli/src/commands/git/binding.rs:711–737  ·  view source on GitHub ↗
(
    git: &GitRepository,
    ref_name: &str,
    target: git2::Oid,
)

Source from the content-addressed store, hash-verified

709}
710
711fn load_binding_at_ref(
712 git: &GitRepository,
713 ref_name: &str,
714 target: git2::Oid,
715) -> CliResult<GitStateBinding> {
716 let commit = git.find_commit(target).map_err(|error| {
717 git_map(format!(
718 "binding ref '{ref_name}' points at a missing commit: {error}"
719 ))
720 })?;
721 let tree = commit
722 .tree()
723 .map_err(|error| git_map(format!("binding ref '{ref_name}' has no tree: {error}")))?;
724 let entry = tree.get_name("binding.cbor").ok_or_else(|| {
725 git_map(format!(
726 "binding ref '{ref_name}' does not carry binding.cbor"
727 ))
728 })?;
729 let blob = git
730 .find_blob(entry.id())
731 .map_err(|error| git_map(format!("binding ref '{ref_name}' blob missing: {error}")))?;
732 GitStateBinding::decode(blob.content()).map_err(|error| {
733 git_map(format!(
734 "binding ref '{ref_name}' carries invalid binding bytes: {error}"
735 ))
736 })
737}
738
739/// Closure acquisition through the CLI (CB-6B, RFC §8.6): Atomic remote
740/// first, the binding's bounded `changes.pack` as verified fallback.

Callers 1

Calls 5

treeMethod · 0.80
git_mapFunction · 0.70
decodeFunction · 0.50
idMethod · 0.45
contentMethod · 0.45

Tested by

no test coverage detected