Get all local branch names.
(&self, git_repo: &GitRepository)
| 303 | |
| 304 | /// Get all local branch names. |
| 305 | fn get_all_branches(&self, git_repo: &GitRepository) -> CliResult<Vec<String>> { |
| 306 | let branches = git_repo |
| 307 | .branches(Some(git2::BranchType::Local)) |
| 308 | .map_err(|e| CliError::GitError { |
| 309 | message: format!("Failed to list branches: {}", e), |
| 310 | })?; |
| 311 | |
| 312 | let mut names = Vec::new(); |
| 313 | for branch_result in branches { |
| 314 | let (branch, _) = branch_result.map_err(|e| CliError::GitError { |
| 315 | message: format!("Failed to get branch: {}", e), |
| 316 | })?; |
| 317 | if let Some(name) = branch.name().ok().flatten() { |
| 318 | names.push(name.to_string()); |
| 319 | } |
| 320 | } |
| 321 | |
| 322 | Ok(names) |
| 323 | } |
| 324 | |
| 325 | /// Get the default branch name. |
| 326 | fn get_default_branch(&self, git_repo: &GitRepository) -> CliResult<String> { |