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:2237–2266  ·  view source on GitHub ↗
(root: &Path)

Source from the content-addressed store, hash-verified

2235}
2236
2237pub(crate) fn refresh_checkpoint_if_aligned(root: &Path) -> CliResult<CheckpointRefresh> {
2238 let observation = observe_git(root).map_err(observation_error)?;
2239 let GitObservation::Repository(git) = observation else {
2240 return Ok(CheckpointRefresh::SkippedNoGit);
2241 };
2242 let HeadObservation::Attached { symref, .. } = &git.head else {
2243 // CB-8A: a Draft view under the view-scope HEAD policy stays detached
2244 // at its projection commit (RFC §8.1). When the detached commit is
2245 // exactly the draft's verified projection, the checkpoint is
2246 // refreshed the same way an attached Shared switch would be.
2247 return refresh_detached_checkpoint(root, &git.head);
2248 };
2249 let Some(branch) = symref.strip_prefix("refs/heads/") else {
2250 return Ok(CheckpointRefresh::SkippedUnsupportedHead);
2251 };
2252
2253 let current_view = {
2254 let repo = Repository::open(root).map_err(CliError::from)?;
2255 let working_copy = repo.require_working_copy_id().map_err(CliError::from)?;
2256 repo.desired_view_name(working_copy)
2257 .map_err(CliError::from)?
2258 };
2259 if branch != current_view {
2260 return Ok(CheckpointRefresh::SkippedViewMismatch);
2261 }
2262
2263 let snapshot = verify_at(root)?;
2264 write_workspace_metadata(root, &snapshot)?;
2265 Ok(CheckpointRefresh::Refreshed)
2266}
2267
2268/// Refresh the verified checkpoint for a detached HEAD (CB-8A Draft policy).
2269///

Callers 4

run_importMethod · 0.85
checkpoint_shadow_switchFunction · 0.85

Calls 7

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

Tested by

no test coverage detected