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

Method reobserve_for_git_push

atomic-cli/src/commands/git/shadow.rs:151–174  ·  view source on GitHub ↗
(
        &self,
        repo: &Repository,
        repo_root: &Path,
        git_repo: &GitRepository,
    )

Source from the content-addressed store, hash-verified

149 }
150
151 pub(crate) fn reobserve_for_git_push(
152 &self,
153 repo: &Repository,
154 repo_root: &Path,
155 git_repo: &GitRepository,
156 ) -> CliResult<()> {
157 self.reobserve(repo, repo_root)?;
158 let expected = self
159 .git_head
160 .ok_or_else(|| git_error("cannot publish an unborn Git HEAD"))?;
161 let head = git_repo
162 .head()
163 .and_then(|head| head.peel_to_commit())
164 .map_err(|error| git_error(format!("cannot re-observe Git HEAD: {error}")))?;
165 if head.id() != expected || head.tree_id() != self.git_tree_oid()? {
166 return Err(git_error(format!(
167 "Git HEAD lease changed before push: expected commit {expected} with tree {}, found commit {} with tree {}",
168 self.git_tree_oid()?,
169 head.id(),
170 head.tree_id()
171 )));
172 }
173 Ok(())
174 }
175
176 /// Re-observe every lease represented by this capability. This rejects an
177 /// Atomic view/state change, policy change, index edit, or worktree edit.

Callers 1

push_to_remoteMethod · 0.80

Calls 5

reobserveMethod · 0.80
git_tree_oidMethod · 0.80
git_errorFunction · 0.70
headMethod · 0.45
idMethod · 0.45

Tested by

no test coverage detected