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