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

Method get_default_branch

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

Get the default branch name.

(&self, git_repo: &GitRepository)

Source from the content-addressed store, hash-verified

324
325 /// Get the default branch name.
326 fn get_default_branch(&self, git_repo: &GitRepository) -> CliResult<String> {
327 // Try HEAD first (current branch)
328 if let Some(name) = current_git_branch(git_repo) {
329 return Ok(name);
330 }
331
332 // Fall back to common default names
333 for name in &["main", "master"] {
334 if git_repo.find_branch(name, git2::BranchType::Local).is_ok() {
335 return Ok(name.to_string());
336 }
337 }
338
339 Err(CliError::GitError {
340 message: "Could not determine default branch".to_string(),
341 })
342 }
343
344 /// Count commits for dry-run mode.
345 fn count_commits(

Callers 1

runMethod · 0.80

Calls 1

current_git_branchFunction · 0.85

Tested by

no test coverage detected