()
| 20 | } |
| 21 | |
| 22 | fn codebuff_project_roots() -> Result<Vec<PathBuf>> { |
| 23 | let roots = if let Ok(paths) = env::var(CODEBUFF_DATA_DIR_ENV) { |
| 24 | paths |
| 25 | .split(',') |
| 26 | .map(str::trim) |
| 27 | .filter(|path| !path.is_empty()) |
| 28 | .map(PathBuf::from) |
| 29 | .collect::<Vec<_>>() |
| 30 | } else { |
| 31 | let home = |
| 32 | crate::home::home_dir().ok_or_else(|| crate::cli_error("home directory is not set"))?; |
| 33 | CHANNELS |
| 34 | .iter() |
| 35 | .map(|channel| home.join(".config").join(channel)) |
| 36 | .collect() |
| 37 | }; |
| 38 | let mut seen = HashSet::new(); |
| 39 | let mut project_roots = Vec::new(); |
| 40 | for root in roots { |
| 41 | let project_root = if root.file_name().is_some_and(|name| name == "projects") { |
| 42 | root |
| 43 | } else { |
| 44 | root.join("projects") |
| 45 | }; |
| 46 | if project_root.is_dir() && seen.insert(project_root.clone()) { |
| 47 | project_roots.push(project_root); |
| 48 | } |
| 49 | } |
| 50 | Ok(project_roots) |
| 51 | } |
no test coverage detected