(
staging: &StagingState,
shim: &ShimSummary,
ignore: &atomic_repository::IgnorePolicyReport,
shelved: &[String],
remediation_notice: Option<&str>,
)
| 341 | } |
| 342 | |
| 343 | fn git_status_json( |
| 344 | staging: &StagingState, |
| 345 | shim: &ShimSummary, |
| 346 | ignore: &atomic_repository::IgnorePolicyReport, |
| 347 | shelved: &[String], |
| 348 | remediation_notice: Option<&str>, |
| 349 | ) -> serde_json::Value { |
| 350 | let staged: Vec<serde_json::Value> = staging |
| 351 | .entries |
| 352 | .iter() |
| 353 | .filter(|entry| entry.x != StageCode::Unmodified) |
| 354 | .map(entry_json) |
| 355 | .collect(); |
| 356 | let unstaged: Vec<serde_json::Value> = staging |
| 357 | .entries |
| 358 | .iter() |
| 359 | .filter(|entry| entry.y != StageCode::Unmodified) |
| 360 | .map(entry_json) |
| 361 | .collect(); |
| 362 | let untracked: Vec<String> = staging |
| 363 | .untracked() |
| 364 | .map(|entry| quote_path(entry.path.as_bytes())) |
| 365 | .collect(); |
| 366 | let mut notices = describe_notices(&staging.notices); |
| 367 | if let Some(remediation_notice) = remediation_notice { |
| 368 | notices.push(remediation_notice.to_string()); |
| 369 | } |
| 370 | if ignore.diverges() { |
| 371 | notices.push(format!( |
| 372 | "ignore-policy divergence: {} unmirrored .atomicignore pattern(s): {}", |
| 373 | ignore.unmirrored.len(), |
| 374 | ignore.unmirrored.join(", ") |
| 375 | )); |
| 376 | } |
| 377 | |
| 378 | serde_json::json!({ |
| 379 | "format": "atomic-status-git", |
| 380 | "version": GIT_STATUS_JSON_VERSION, |
| 381 | "clean": staging.is_clean(), |
| 382 | "shim": { |
| 383 | "state": shim.state, |
| 384 | "origin": shim.origin, |
| 385 | "view": shim.view, |
| 386 | "atomic_state": shim.atomic_state, |
| 387 | "git_head": shim.git_head, |
| 388 | "git_tree": shim.git_tree, |
| 389 | }, |
| 390 | "layers": { |
| 391 | "baseline_tree": staging.baseline_tree.as_ref().map(git_object_id_hex), |
| 392 | "index_tree": staging.index_tree.as_ref().map(git_object_id_hex), |
| 393 | "durable_manifest_root": staging.durable_manifest_root.as_ref().map(|root| root.content_key.clone()), |
| 394 | "snapshot": staging.snapshot.as_ref().map(|hash| hash.to_base32()), |
| 395 | "remainder": staging.remainder.as_ref().map(|hash| hash.to_base32()), |
| 396 | }, |
| 397 | "staged": staged, |
| 398 | "unstaged": unstaged, |
| 399 | "untracked": untracked, |
| 400 | "notices": notices, |
no test coverage detected