Get all local branch names.
(&self, git_repo: &GitRepository)
| 356 | |
| 357 | /// Get all local branch names. |
| 358 | fn get_all_branches(&self, git_repo: &GitRepository) -> CliResult<Vec<String>> { |
| 359 | let branches = git_repo |
| 360 | .branches(Some(git2::BranchType::Local)) |
| 361 | .map_err(|e| CliError::GitError { |
| 362 | message: format!("Failed to list branches: {}", e), |
| 363 | })?; |
| 364 | |
| 365 | let mut names = Vec::new(); |
| 366 | for branch_result in branches { |
| 367 | let (branch, _) = branch_result.map_err(|e| CliError::GitError { |
| 368 | message: format!("Failed to get branch: {}", e), |
| 369 | })?; |
| 370 | if let Some(name) = branch.name().ok().flatten() { |
| 371 | names.push(name.to_string()); |
| 372 | } |
| 373 | } |
| 374 | |
| 375 | Ok(names) |
| 376 | } |
| 377 | |
| 378 | /// Get the default branch name. |
| 379 | fn get_default_branch(&self, git_repo: &GitRepository) -> CliResult<String> { |