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>)
| 1223 | /// directive body, then index it into the KG. Reuses the created entry's |
| 1224 | /// frontmatter so manifest resolution keeps working. |
| 1225 | fn install_intent_body(repo: &Repository, intent_file: &str, body: &str, status: Option<&str>) { |
| 1226 | use atomic_core::pristine::VaultEntryType; |
| 1227 | let entry = repo.vault_retrieve(intent_file).unwrap().unwrap(); |
| 1228 | let frontmatter_json = match status { |
| 1229 | Some(s) => { |
| 1230 | let mut fm: serde_json::Map<String, serde_json::Value> = |
| 1231 | serde_json::from_str(&entry.frontmatter_json).unwrap(); |
| 1232 | fm.insert("status".into(), serde_json::Value::String(s.to_string())); |
| 1233 | serde_json::to_string(&fm).unwrap() |
| 1234 | } |
| 1235 | None => entry.frontmatter_json.clone(), |
| 1236 | }; |
| 1237 | repo.vault_store( |
| 1238 | intent_file, |
| 1239 | VaultEntryType::Intent, |
| 1240 | body.as_bytes().to_vec(), |
| 1241 | frontmatter_json, |
| 1242 | ) |
| 1243 | .unwrap(); |
| 1244 | repo.vault_index_kg(intent_file).unwrap(); |
| 1245 | } |
| 1246 | |
| 1247 | /// Like `install_intent_body` but sets arbitrary frontmatter string fields |
| 1248 | /// (e.g. `kind`, `attributedTo`, `status`) so tests can control the review |
no test coverage detected