Mirror `attest`'s legacy sidecar write exactly ({node, source} wrapper).
(
repo: &Repository,
id: &str,
node: &CanonicalNode,
inputs: &LiftInputs,
)
| 434 | |
| 435 | /// Mirror `attest`'s legacy sidecar write exactly ({node, source} wrapper). |
| 436 | fn write_legacy_sidecar( |
| 437 | repo: &Repository, |
| 438 | id: &str, |
| 439 | node: &CanonicalNode, |
| 440 | inputs: &LiftInputs, |
| 441 | ) { |
| 442 | let path = attested_sidecar_path(repo, id).unwrap(); |
| 443 | std::fs::create_dir_all(path.parent().unwrap()).unwrap(); |
| 444 | let mut artifact = serde_json::Map::new(); |
| 445 | artifact.insert("node".to_string(), node.to_value()); |
| 446 | let mut source = serde_json::Map::new(); |
| 447 | source.insert( |
| 448 | "sourceContentHash".to_string(), |
| 449 | Value::String(source_content_hash(inputs)), |
| 450 | ); |
| 451 | artifact.insert("source".to_string(), Value::Object(source)); |
| 452 | std::fs::write( |
| 453 | &path, |
| 454 | serde_json::to_string_pretty(&Value::Object(artifact)).unwrap(), |
| 455 | ) |
| 456 | .unwrap(); |
| 457 | } |
| 458 | |
| 459 | #[test] |
| 460 | fn test_load_attestation_prefers_tracked_then_legacy() { |