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

Method get_default_branch

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

Get the default branch name.

(&self, git_repo: &GitRepository)

Source from the content-addressed store, hash-verified

311
312 /// Get the default branch name.
313 fn get_default_branch(&self, git_repo: &GitRepository) -> CliResult<String> {
314 // Try HEAD first (current branch)
315 if let Some(name) = current_git_branch(git_repo) {
316 return Ok(name);
317 }
318
319 // Fall back to common default names
320 for name in &["main", "master"] {
321 if git_repo.find_branch(name, git2::BranchType::Local).is_ok() {
322 return Ok(name.to_string());
323 }
324 }
325
326 Err(CliError::GitError {
327 message: "Could not determine default branch".to_string(),
328 })
329 }
330
331 /// Count commits for dry-run mode.
332 fn count_commits(

Callers 1

runMethod · 0.80

Calls 1

current_git_branchFunction · 0.85

Tested by

no test coverage detected