| 8 | use crate::commit_pattern::CommitPattern; |
| 9 | |
| 10 | fn select_custom_config_path(config: Option<PathBuf>) -> Result<PathBuf> { |
| 11 | match config { |
| 12 | Some(config_path) => { |
| 13 | if config_path.exists() { |
| 14 | if !config_path.is_file() { |
| 15 | return Err(anyhow!( |
| 16 | "Config file path is not a file: {}", |
| 17 | config_path.display() |
| 18 | )); |
| 19 | } |
| 20 | Ok(config_path) |
| 21 | } else { |
| 22 | Err(anyhow!( |
| 23 | "Config file does not exist: {}", |
| 24 | config_path.display() |
| 25 | )) |
| 26 | } |
| 27 | } |
| 28 | None => get_config_path(), |
| 29 | } |
| 30 | } |
| 31 | |
| 32 | fn search_config_file_on_parents() -> Result<Option<PathBuf>> { |
| 33 | let current_dir = std::env::current_dir()?; |