Get all local branch names.
(&self, git_repo: &GitRepository)
| 290 | |
| 291 | /// Get all local branch names. |
| 292 | fn get_all_branches(&self, git_repo: &GitRepository) -> CliResult<Vec<String>> { |
| 293 | let branches = git_repo |
| 294 | .branches(Some(git2::BranchType::Local)) |
| 295 | .map_err(|e| CliError::GitError { |
| 296 | message: format!("Failed to list branches: {}", e), |
| 297 | })?; |
| 298 | |
| 299 | let mut names = Vec::new(); |
| 300 | for branch_result in branches { |
| 301 | let (branch, _) = branch_result.map_err(|e| CliError::GitError { |
| 302 | message: format!("Failed to get branch: {}", e), |
| 303 | })?; |
| 304 | if let Some(name) = branch.name().ok().flatten() { |
| 305 | names.push(name.to_string()); |
| 306 | } |
| 307 | } |
| 308 | |
| 309 | Ok(names) |
| 310 | } |
| 311 | |
| 312 | /// Get the default branch name. |
| 313 | fn get_default_branch(&self, git_repo: &GitRepository) -> CliResult<String> { |