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