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

Method get_all_branches

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

Get all local branch names.

(&self, git_repo: &GitRepository)

Source from the content-addressed store, hash-verified

327
328 /// Get all local branch names.
329 fn get_all_branches(&self, git_repo: &GitRepository) -> CliResult<Vec<String>> {
330 let branches = git_repo
331 .branches(Some(git2::BranchType::Local))
332 .map_err(|e| CliError::GitError {
333 message: format!("Failed to list branches: {}", e),
334 })?;
335
336 let mut names = Vec::new();
337 for branch_result in branches {
338 let (branch, _) = branch_result.map_err(|e| CliError::GitError {
339 message: format!("Failed to get branch: {}", e),
340 })?;
341 if let Some(name) = branch.name().ok().flatten() {
342 names.push(name.to_string());
343 }
344 }
345
346 Ok(names)
347 }
348
349 /// Get the default branch name.
350 fn get_default_branch(&self, git_repo: &GitRepository) -> CliResult<String> {

Callers 1

runMethod · 0.80

Calls 2

nameMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected