(root: &Path)
| 2191 | } |
| 2192 | |
| 2193 | pub(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 | /// |
no test coverage detected