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

Method get_all_branches

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

Get all local branch names.

(&self, git_repo: &GitRepository)

Source from the content-addressed store, hash-verified

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

Callers 1

run_importMethod · 0.80

Calls 3

okMethod · 0.45
nameMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected