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

Function clear_worktree

atomic-cli/tests/it/graph_only_export_cb9b_test.rs:114–129  ·  view source on GitHub ↗

Delete every physical file under `root` except `.git`/`.atomic`, so any subsequent content read can only come from the recorded graph.

(root: &Path)

Source from the content-addressed store, hash-verified

112/// Delete every physical file under `root` except `.git`/`.atomic`, so any
113/// subsequent content read can only come from the recorded graph.
114fn clear_worktree(root: &Path) {
115 for entry in fs::read_dir(root).unwrap() {
116 let entry = entry.unwrap();
117 let name = entry.file_name();
118 let name = name.to_string_lossy();
119 if name == ".git" || name == ".atomic" || name == ".vault" {
120 continue;
121 }
122 let path = entry.path();
123 if path.is_dir() {
124 fs::remove_dir_all(&path).unwrap();
125 } else {
126 fs::remove_file(&path).unwrap();
127 }
128 }
129}
130
131/// Export a set of paths from the recorded graph and return the bytes.
132fn graph_export(root: &Path, view: &str, paths: &[&str]) -> (Vec<(String, Vec<u8>)>, Duration) {

Calls 4

is_dirMethod · 0.80
unwrapMethod · 0.45
file_nameMethod · 0.45
pathMethod · 0.45

Tested by

no test coverage detected