reinhardt_admin_cli/migrate_v2/
walker.rs1use std::path::{Path, PathBuf};
4
5use walkdir::WalkDir;
6
7pub fn find_rs_files(root: &Path) -> anyhow::Result<Vec<PathBuf>> {
12 let mut out = Vec::new();
13 for entry in WalkDir::new(root)
14 .into_iter()
15 .filter_entry(|e| !is_skipped_descendant(root, e.path()))
16 {
17 let entry = entry?;
18 if entry.file_type().is_file()
19 && entry.path().extension().map(|e| e == "rs").unwrap_or(false)
20 {
21 out.push(entry.into_path());
22 }
23 }
24 out.sort();
25 Ok(out)
26}
27
28fn is_skipped_descendant(root: &Path, p: &Path) -> bool {
29 if p == root {
31 return false;
32 }
33 let name = p.file_name().and_then(|s| s.to_str()).unwrap_or("");
34 if name == "target" {
40 return true;
41 }
42 p.is_dir() && name.starts_with('.')
43}