Mirror `attest`'s legacy sidecar write exactly ({node, source} wrapper).
(
repo: &Repository,
id: &str,
node: &CanonicalNode,
inputs: &LiftInputs,
)
| 507 | |
| 508 | /// Mirror `attest`'s legacy sidecar write exactly ({node, source} wrapper). |
| 509 | fn write_legacy_sidecar( |
| 510 | repo: &Repository, |
| 511 | id: &str, |
| 512 | node: &CanonicalNode, |
| 513 | inputs: &LiftInputs, |
| 514 | ) { |
| 515 | let path = attested_sidecar_path(repo, id).unwrap(); |
| 516 | std::fs::create_dir_all(path.parent().unwrap()).unwrap(); |
| 517 | let mut artifact = serde_json::Map::new(); |
| 518 | artifact.insert("node".to_string(), node.to_value()); |
| 519 | let mut source = serde_json::Map::new(); |
| 520 | source.insert( |
| 521 | "sourceContentHash".to_string(), |
| 522 | Value::String(source_content_hash(inputs)), |
| 523 | ); |
| 524 | artifact.insert("source".to_string(), Value::Object(source)); |
| 525 | std::fs::write( |
| 526 | &path, |
| 527 | serde_json::to_string_pretty(&Value::Object(artifact)).unwrap(), |
| 528 | ) |
| 529 | .unwrap(); |
| 530 | } |
| 531 | |
| 532 | #[test] |
| 533 | fn test_load_attestation_prefers_tracked_then_legacy() { |