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

Function enable_watch

atomic-cli/tests/it/import_budget_100k_bench.rs:441–471  ·  view source on GitHub ↗
(root: &Path)

Source from the content-addressed store, hash-verified

439}
440
441fn enable_watch(root: &Path) {
442 let config = root.join(".atomic/config.toml");
443 let content = fs::read_to_string(&config).expect("read repo config");
444 assert!(
445 content.contains("[git.shim]"),
446 "shim enable must have recorded the consent table first"
447 );
448 let mut in_watch = false;
449 let mut flipped = false;
450 let rewritten: String = content
451 .lines()
452 .map(|line| {
453 if line.trim() == "[git.shim.watch]" {
454 in_watch = true;
455 return line.to_string();
456 }
457 if line.trim().starts_with('[') {
458 in_watch = false;
459 return line.to_string();
460 }
461 if in_watch && line.trim() == "enabled = false" {
462 flipped = true;
463 return "enabled = true".to_string();
464 }
465 line.to_string()
466 })
467 .collect::<Vec<_>>()
468 .join("\n");
469 assert!(flipped, "the disabled watch default must be present");
470 fs::write(config, rewritten + "\n").expect("write repo config");
471}
472
473/// Byte snapshot of the working tree (excluding .git/.atomic), order-
474/// independent: (relative path, bytes) pairs hashed by serialization.

Callers 1

buildMethod · 0.70

Calls 2

writeFunction · 0.70
linesMethod · 0.45

Tested by

no test coverage detected