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