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

Function refresh_checkpoint_if_aligned

atomic-cli/src/commands/git/shim.rs:2193–2222  ·  view source on GitHub ↗
(root: &Path)

Source from the content-addressed store, hash-verified

2191}
2192
2193pub(crate) fn refresh_checkpoint_if_aligned(root: &Path) -> CliResult<CheckpointRefresh> {
2194 let observation = observe_git(root).map_err(observation_error)?;
2195 let GitObservation::Repository(git) = observation else {
2196 return Ok(CheckpointRefresh::SkippedNoGit);
2197 };
2198 let HeadObservation::Attached { symref, .. } = &git.head else {
2199 // CB-8A: a Draft view under the view-scope HEAD policy stays detached
2200 // at its projection commit (RFC §8.1). When the detached commit is
2201 // exactly the draft's verified projection, the checkpoint is
2202 // refreshed the same way an attached Shared switch would be.
2203 return refresh_detached_checkpoint(root, &git.head);
2204 };
2205 let Some(branch) = symref.strip_prefix("refs/heads/") else {
2206 return Ok(CheckpointRefresh::SkippedUnsupportedHead);
2207 };
2208
2209 let current_view = {
2210 let repo = Repository::open(root).map_err(CliError::from)?;
2211 let working_copy = repo.require_working_copy_id().map_err(CliError::from)?;
2212 repo.desired_view_name(working_copy)
2213 .map_err(CliError::from)?
2214 };
2215 if branch != current_view {
2216 return Ok(CheckpointRefresh::SkippedViewMismatch);
2217 }
2218
2219 let snapshot = verify_at(root)?;
2220 write_workspace_metadata(root, &snapshot)?;
2221 Ok(CheckpointRefresh::Refreshed)
2222}
2223
2224/// Refresh the verified checkpoint for a detached HEAD (CB-8A Draft policy).
2225///

Callers 3

run_importMethod · 0.85
checkpoint_shadow_switchFunction · 0.85

Calls 7

observe_gitFunction · 0.85
openFunction · 0.85
verify_atFunction · 0.85
write_workspace_metadataFunction · 0.85
desired_view_nameMethod · 0.80

Tested by

no test coverage detected