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

Method get_default_branch

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

Get the default branch name.

(&self, git_repo: &GitRepository)

Source from the content-addressed store, hash-verified

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

Callers 1

run_importMethod · 0.80

Calls 1

current_git_branchFunction · 0.85

Tested by

no test coverage detected