Overwrite a created intent's body (and optionally its status) with a directive body, then index it into the KG. Reuses the created entry's frontmatter so manifest resolution keeps working.
(repo: &Repository, intent_file: &str, body: &str, status: Option<&str>)
| 1188 | /// directive body, then index it into the KG. Reuses the created entry's |
| 1189 | /// frontmatter so manifest resolution keeps working. |
| 1190 | fn install_intent_body(repo: &Repository, intent_file: &str, body: &str, status: Option<&str>) { |
| 1191 | use atomic_core::pristine::VaultEntryType; |
| 1192 | let entry = repo.vault_retrieve(intent_file).unwrap().unwrap(); |
| 1193 | let frontmatter_json = match status { |
| 1194 | Some(s) => { |
| 1195 | let mut fm: serde_json::Map<String, serde_json::Value> = |
| 1196 | serde_json::from_str(&entry.frontmatter_json).unwrap(); |
| 1197 | fm.insert("status".into(), serde_json::Value::String(s.to_string())); |
| 1198 | serde_json::to_string(&fm).unwrap() |
| 1199 | } |
| 1200 | None => entry.frontmatter_json.clone(), |
| 1201 | }; |
| 1202 | repo.vault_store( |
| 1203 | intent_file, |
| 1204 | VaultEntryType::Intent, |
| 1205 | body.as_bytes().to_vec(), |
| 1206 | frontmatter_json, |
| 1207 | ) |
| 1208 | .unwrap(); |
| 1209 | repo.vault_index_kg(intent_file).unwrap(); |
| 1210 | } |
| 1211 | |
| 1212 | /// Like `install_intent_body` but sets arbitrary frontmatter string fields |
| 1213 | /// (e.g. `kind`, `attributedTo`, `status`) so tests can control the review |
no test coverage detected