MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / get_all_branches

Method get_all_branches

atomic-cli/src/commands/git/import.rs:602–620  ·  view source on GitHub ↗

Get all local branch names.

(&self, git_repo: &GitRepository)

Source from the content-addressed store, hash-verified

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> {

Callers 1

run_importMethod · 0.80

Calls 3

okMethod · 0.45
nameMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected