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

Function collect_shelved_artifacts

atomic-cli/src/commands/status_git.rs:272–303  ·  view source on GitHub ↗
(repo_root: &Path, view: &str)

Source from the content-addressed store, hash-verified

270}
271
272fn collect_shelved_artifacts(repo_root: &Path, view: &str) -> Vec<String> {
273 let dot_dir = repo_root.join(".atomic");
274 let mut roots = vec![
275 // Per-working-copy shelf artifacts take precedence when present.
276 dot_dir.join("working-copies"),
277 dot_dir.join("workspaces").join(view),
278 ];
279 let mut output = Vec::new();
280 let working_copy_root = roots.remove(0);
281 // Enumerate every working copy's shelf for this view plus the legacy
282 // per-view directory, deterministically.
283 let mut candidates: Vec<PathBuf> = Vec::new();
284 if let Ok(entries) = std::fs::read_dir(&working_copy_root) {
285 for entry in entries.flatten() {
286 let candidate = entry.path().join("workspaces").join(view);
287 if candidate.is_dir() {
288 candidates.push(candidate);
289 }
290 }
291 }
292 let legacy = roots.remove(0);
293 if legacy.is_dir() {
294 candidates.push(legacy);
295 }
296 candidates.sort();
297 for candidate in candidates {
298 collect_files(&candidate, &candidate, &mut output, 0);
299 }
300 output.sort();
301 output.dedup();
302 output
303}
304
305fn collect_files(base: &Path, directory: &Path, output: &mut Vec<String>, depth: usize) {
306 if depth > 8 {

Callers 1

run_git_statusFunction · 0.85

Calls 6

is_dirMethod · 0.80
sortMethod · 0.80
collect_filesFunction · 0.70
removeMethod · 0.65
pathMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected