Get all local branch names.
(&self, git_repo: &GitRepository)
| 593 | |
| 594 | /// Get all local branch names. |
| 595 | fn get_all_branches(&self, git_repo: &GitRepository) -> CliResult<Vec<String>> { |
| 596 | let branches = git_repo |
| 597 | .branches(Some(git2::BranchType::Local)) |
| 598 | .map_err(|e| CliError::GitError { |
| 599 | message: format!("Failed to list branches: {}", e), |
| 600 | })?; |
| 601 | |
| 602 | let mut names = Vec::new(); |
| 603 | for branch_result in branches { |
| 604 | let (branch, _) = branch_result.map_err(|e| CliError::GitError { |
| 605 | message: format!("Failed to get branch: {}", e), |
| 606 | })?; |
| 607 | if let Some(name) = branch.name().ok().flatten() { |
| 608 | names.push(name.to_string()); |
| 609 | } |
| 610 | } |
| 611 | |
| 612 | Ok(names) |
| 613 | } |
| 614 | |
| 615 | /// Get the default branch name. |
| 616 | fn get_default_branch(&self, git_repo: &GitRepository) -> CliResult<String> { |
no test coverage detected