Get the default branch name.
(&self, git_repo: &GitRepository)
| 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 | /// |
no test coverage detected