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

Method bind_committed_head

atomic-cli/src/commands/git/shadow.rs:103–132  ·  view source on GitHub ↗
(
        &mut self,
        git_repo: &GitRepository,
        commit_oid: git2::Oid,
    )

Source from the content-addressed store, hash-verified

101 }
102
103 pub(crate) fn bind_committed_head(
104 &mut self,
105 git_repo: &GitRepository,
106 commit_oid: git2::Oid,
107 ) -> CliResult<()> {
108 let commit = git_repo.find_commit(commit_oid).map_err(|error| {
109 git_error(format!(
110 "cannot bind published Git commit {commit_oid}: {error}"
111 ))
112 })?;
113 if commit.tree_id() != self.git_tree_oid()? {
114 return Err(git_error(
115 "refusing to bind a Git commit whose tree differs from the verified project tree",
116 ));
117 }
118 let observed = git_repo
119 .head()
120 .ok()
121 .and_then(|head| head.target())
122 .ok_or_else(|| {
123 git_error("cannot bind publication to an unborn or symbolic-only HEAD")
124 })?;
125 if observed != commit_oid {
126 return Err(git_error(format!(
127 "Git HEAD changed while binding publication: expected {commit_oid}, found {observed}"
128 )));
129 }
130 self.git_head = Some(commit_oid);
131 Ok(())
132 }
133
134 pub(crate) fn reobserve_before_commit(
135 &self,

Callers 1

runMethod · 0.80

Calls 4

git_tree_oidMethod · 0.80
git_errorFunction · 0.70
okMethod · 0.45
headMethod · 0.45

Tested by

no test coverage detected