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

Method worktree_snapshot

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

Working-copy byte snapshot (conversion-policy relevant files only; .git and .atomic excluded).

(&self)

Source from the content-addressed store, hash-verified

347 /// Working-copy byte snapshot (conversion-policy relevant files only;
348 /// .git and .atomic excluded).
349 fn worktree_snapshot(&self) -> String {
350 let mut snapshot = String::new();
351 let mut stack = vec![self.root().to_path_buf()];
352 while let Some(directory) = stack.pop() {
353 for entry in fs::read_dir(&directory).expect("read dir").flatten() {
354 let path = entry.path();
355 let name = path.file_name().and_then(|name| name.to_str());
356 if name == Some(".git") || name == Some(".atomic") {
357 continue;
358 }
359 if path.is_dir() {
360 stack.push(path);
361 } else if let Ok(bytes) = fs::read(&path) {
362 snapshot.push_str(&format!(
363 "{}\t{:?}\n",
364 path.strip_prefix(self.root())
365 .expect("relative path")
366 .display(),
367 bytes
368 ));
369 }
370 }
371 }
372 snapshot
373 }
374
375 /// The logical state identity used for watcher-off equivalence: the
376 /// content-derived manifest roots (identical across repositories for

Calls 5

is_dirMethod · 0.80
readFunction · 0.70
pathMethod · 0.45
file_nameMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected