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

Method get_default_branch

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

Get the default branch name.

(&self, git_repo: &GitRepository)

Source from the content-addressed store, hash-verified

614
615 /// Get the default branch name.
616 fn get_default_branch(&self, git_repo: &GitRepository) -> CliResult<String> {
617 // Try HEAD first (current branch)
618 if let Some(name) = current_git_branch(git_repo) {
619 return Ok(name);
620 }
621
622 // Fall back to common default names
623 for name in &["main", "master"] {
624 if git_repo.find_branch(name, git2::BranchType::Local).is_ok() {
625 return Ok(name.to_string());
626 }
627 }
628
629 Err(CliError::GitError {
630 message: "Could not determine default branch".to_string(),
631 })
632 }
633
634 /// Count the commits a real import would create, for dry-run mode.
635 ///

Callers 1

run_importMethod · 0.80

Calls 1

current_git_branchFunction · 0.85

Tested by

no test coverage detected