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

Method shelved_files

atomic-cli/tests/it/git_adoption_cb7b_test.rs:273–303  ·  view source on GitHub ↗

The shelved files across every view workspace, as (path, bytes).

(&self)

Source from the content-addressed store, hash-verified

271
272 /// The shelved files across every view workspace, as (path, bytes).
273 fn shelved_files(&self) -> Vec<(String, Vec<u8>)> {
274 let mut shelved = Vec::new();
275 let workspaces = self.root().join(".atomic/working-copies");
276 if !workspaces.is_dir() {
277 return shelved;
278 }
279 fn walk(dir: &Path, base: &Path, out: &mut Vec<(String, Vec<u8>)>) {
280 for entry in fs::read_dir(dir).expect("walk shelf") {
281 let entry = entry.expect("entry");
282 let path = entry.path();
283 if path.is_dir() {
284 walk(&path, base, out);
285 } else {
286 let relative = path
287 .strip_prefix(base)
288 .expect("relative")
289 .to_string_lossy()
290 .into_owned();
291 out.push((relative, fs::read(&path).expect("shelf bytes")));
292 }
293 }
294 }
295 for entry in fs::read_dir(&workspaces).expect("walk workspaces") {
296 let dir = entry.expect("entry").path().join("workspaces");
297 if dir.is_dir() {
298 walk(&dir, &dir, &mut shelved);
299 }
300 }
301 shelved.sort();
302 shelved
303 }
304}
305
306// ── AC-1: known carried edit re-assembly ─────────────────────────────────

Calls 5

is_dirMethod · 0.80
sortMethod · 0.80
walkFunction · 0.70
rootMethod · 0.45
pathMethod · 0.45

Tested by

no test coverage detected