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