The desired view's mapped ref tip must agree with the Git branch tip (CB-10A): a branch that moved without the mapping is divergent evidence.
(repo: &Repository, root: &Path, view_name: &str)
| 313 | /// The desired view's mapped ref tip must agree with the Git branch tip |
| 314 | /// (CB-10A): a branch that moved without the mapping is divergent evidence. |
| 315 | fn ref_mapping_census_class(repo: &Repository, root: &Path, view_name: &str) -> CensusClass { |
| 316 | let name = "census/refs"; |
| 317 | let class = (|| -> Result<CensusClass, String> { |
| 318 | let git = git2::Repository::open(root).map_err(|e| e.to_string())?; |
| 319 | let branch_ref = format!("refs/heads/{view_name}"); |
| 320 | let branch_tip = git |
| 321 | .find_reference(&branch_ref) |
| 322 | .ok() |
| 323 | .and_then(|reference| reference.peel_to_commit().ok()) |
| 324 | .map(|commit| commit.id().to_string()); |
| 325 | let Some(branch_tip) = branch_tip else { |
| 326 | return Ok(CensusClass { |
| 327 | name, |
| 328 | clean: true, |
| 329 | detail: format!("no Git branch for view '{view_name}' (nothing to compare)"), |
| 330 | }); |
| 331 | }; |
| 332 | let mapped_tip = super::ref_mapping::mapped_ref_tip(&git, repo, view_name); |
| 333 | match mapped_tip { |
| 334 | Some(tip) if tip == branch_tip => Ok(CensusClass { |
| 335 | name, |
| 336 | clean: true, |
| 337 | detail: format!("mapped ref tip agrees with '{branch_ref}'"), |
| 338 | }), |
| 339 | Some(tip) => Ok(CensusClass { |
| 340 | name, |
| 341 | clean: false, |
| 342 | detail: format!( |
| 343 | "the mapped ref tip {tip} diverges from the branch tip {branch_tip}; \ |
| 344 | run 'atomic git shim status' for the reconciliation state" |
| 345 | ), |
| 346 | }), |
| 347 | None => Ok(CensusClass { |
| 348 | name, |
| 349 | clean: true, |
| 350 | detail: "no mapped-ref observation recorded (mapping not yet established)" |
| 351 | .to_string(), |
| 352 | }), |
| 353 | } |
| 354 | })(); |
| 355 | match class { |
| 356 | Ok(class) => class, |
| 357 | Err(error) => CensusClass { |
| 358 | name, |
| 359 | clean: false, |
| 360 | detail: format!("cannot inspect ref mappings: {error}"), |
| 361 | }, |
| 362 | } |
| 363 | } |
| 364 | |
| 365 | /// The distinct set of class names (for the failure summary). |
| 366 | pub(crate) fn failed_class_names(classes: &[CensusClass]) -> Vec<&'static str> { |
nothing calls this directly
no test coverage detected