Resolve a single config instruction entry to concrete file paths.
(
&self,
instruction: &str,
project_dir: &Path,
worktree: &Path,
)
| 407 | } |
| 408 | /// Resolve a single config instruction entry to concrete file paths. |
| 409 | fn resolve_config_path( |
| 410 | &self, |
| 411 | instruction: &str, |
| 412 | project_dir: &Path, |
| 413 | worktree: &Path, |
| 414 | ) -> Vec<PathBuf> { |
| 415 | let mut expanded = instruction.to_string(); |
| 416 | |
| 417 | // Expand ~/ |
| 418 | if expanded.starts_with("~/") { |
| 419 | if let Some(home) = dirs::home_dir() { |
| 420 | expanded = home.join(&expanded[2..]).to_string_lossy().to_string(); |
| 421 | } |
| 422 | } |
| 423 | |
| 424 | let path = Path::new(&expanded); |
| 425 | |
| 426 | if path.is_absolute() { |
| 427 | if is_glob_pattern(&expanded) { |
| 428 | expand_glob(&expanded, Path::new("/")) |
| 429 | } else if path.is_file() { |
| 430 | vec![path.to_path_buf()] |
| 431 | } else { |
| 432 | Vec::new() |
| 433 | } |
| 434 | } else if is_glob_pattern(&expanded) { |
| 435 | // Relative glob: walk up from project_dir to worktree |
| 436 | if !is_project_config_disabled() { |
| 437 | glob_up(&expanded, project_dir, worktree) |
| 438 | } else if let Some(dir) = opencode_config_dir_env() { |
| 439 | glob_up(&expanded, Path::new(&dir), Path::new(&dir)) |
| 440 | } else { |
| 441 | warn!( |
| 442 | "Skipping relative instruction \"{}\" - no OPENCODE_CONFIG_DIR set while project config is disabled", |
| 443 | instruction |
| 444 | ); |
| 445 | Vec::new() |
| 446 | } |
| 447 | } else { |
| 448 | // Relative plain path: walk up from project_dir to worktree |
| 449 | if !is_project_config_disabled() { |
| 450 | find_up(&expanded, project_dir, worktree) |
| 451 | } else if let Some(dir) = opencode_config_dir_env() { |
| 452 | find_up(&expanded, Path::new(&dir), Path::new(&dir)) |
| 453 | } else { |
| 454 | warn!( |
| 455 | "Skipping relative instruction \"{}\" - no OPENCODE_CONFIG_DIR set while project config is disabled", |
| 456 | instruction |
| 457 | ); |
| 458 | Vec::new() |
| 459 | } |
| 460 | } |
| 461 | } |
| 462 | // ----------------------------------------------------------------------- |
| 463 | // Backward-compatible helpers (kept from original API) |
| 464 | // ----------------------------------------------------------------------- |
no test coverage detected