Remove the watch consent while keeping the shim consent.
(root: &Path)
| 192 | |
| 193 | /// Remove the watch consent while keeping the shim consent. |
| 194 | fn disable_watch(root: &Path) { |
| 195 | let config = root.join(".atomic/config.toml"); |
| 196 | let content = fs::read_to_string(&config).expect("read repo config"); |
| 197 | let mut in_watch = false; |
| 198 | let rewritten: String = content |
| 199 | .lines() |
| 200 | .map(|line| { |
| 201 | if line.trim() == "[git.shim.watch]" { |
| 202 | in_watch = true; |
| 203 | return line.to_string(); |
| 204 | } |
| 205 | if line.trim().starts_with('[') { |
| 206 | in_watch = false; |
| 207 | return line.to_string(); |
| 208 | } |
| 209 | if in_watch && line.trim() == "enabled = true" { |
| 210 | return "enabled = false".to_string(); |
| 211 | } |
| 212 | line.to_string() |
| 213 | }) |
| 214 | .collect::<Vec<_>>() |
| 215 | .join("\n"); |
| 216 | fs::write(config, rewritten).expect("write repo config"); |
| 217 | } |
| 218 | |
| 219 | /// A colocated Git + Atomic repository with the shim enabled and the |
| 220 | /// watch daemon opted in. |
no test coverage detected