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

Method get_default_branch

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

Get the default branch name.

(&self, git_repo: &GitRepository)

Source from the content-addressed store, hash-verified

377
378 /// Get the default branch name.
379 fn get_default_branch(&self, git_repo: &GitRepository) -> CliResult<String> {
380 // Try HEAD first (current branch)
381 if let Some(name) = current_git_branch(git_repo) {
382 return Ok(name);
383 }
384
385 // Fall back to common default names
386 for name in &["main", "master"] {
387 if git_repo.find_branch(name, git2::BranchType::Local).is_ok() {
388 return Ok(name.to_string());
389 }
390 }
391
392 Err(CliError::GitError {
393 message: "Could not determine default branch".to_string(),
394 })
395 }
396
397 /// Count the commits a real import would create, for dry-run mode.
398 ///

Callers 1

runMethod · 0.80

Calls 1

current_git_branchFunction · 0.85

Tested by

no test coverage detected