MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / disable_watch

Function disable_watch

atomic-cli/tests/it/git_shim_cb13d_test.rs:194–217  ·  view source on GitHub ↗

Remove the watch consent while keeping the shim consent.

(root: &Path)

Source from the content-addressed store, hash-verified

192
193/// Remove the watch consent while keeping the shim consent.
194fn 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.

Calls 2

writeFunction · 0.70
linesMethod · 0.45

Tested by

no test coverage detected