Mirror `attest`'s legacy sidecar write exactly ({node, source} wrapper).
(
repo: &Repository,
id: &str,
node: &CanonicalNode,
inputs: &LiftInputs,
)
| 371 | |
| 372 | /// Mirror `attest`'s legacy sidecar write exactly ({node, source} wrapper). |
| 373 | fn write_legacy_sidecar( |
| 374 | repo: &Repository, |
| 375 | id: &str, |
| 376 | node: &CanonicalNode, |
| 377 | inputs: &LiftInputs, |
| 378 | ) { |
| 379 | let path = attested_sidecar_path(repo, id).unwrap(); |
| 380 | std::fs::create_dir_all(path.parent().unwrap()).unwrap(); |
| 381 | let mut artifact = serde_json::Map::new(); |
| 382 | artifact.insert("node".to_string(), node.to_value()); |
| 383 | let mut source = serde_json::Map::new(); |
| 384 | source.insert( |
| 385 | "sourceContentHash".to_string(), |
| 386 | Value::String(source_content_hash(inputs)), |
| 387 | ); |
| 388 | artifact.insert("source".to_string(), Value::Object(source)); |
| 389 | std::fs::write( |
| 390 | &path, |
| 391 | serde_json::to_string_pretty(&Value::Object(artifact)).unwrap(), |
| 392 | ) |
| 393 | .unwrap(); |
| 394 | } |
| 395 | |
| 396 | #[test] |
| 397 | fn test_load_attestation_prefers_tracked_then_legacy() { |