(root: &Path)
| 2235 | } |
| 2236 | |
| 2237 | pub(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 | /// |
no test coverage detected