(&self)
| 377 | |
| 378 | impl Command for Import { |
| 379 | fn run(&self) -> CliResult<()> { |
| 380 | // Open Git repository |
| 381 | let git_repo = GitRepository::discover(".").map_err(|_| CliError::GitError { |
| 382 | message: "Not a git repository (or any parent up to mount point)".to_string(), |
| 383 | })?; |
| 384 | |
| 385 | let workdir = git_repo.workdir().ok_or_else(|| CliError::GitError { |
| 386 | message: "Git repository has no working directory (bare repository?)".to_string(), |
| 387 | })?; |
| 388 | |
| 389 | // Dry run mode |
| 390 | if self.dry_run { |
| 391 | print_info("Dry run mode - no changes will be made"); |
| 392 | |
| 393 | let default_branch = self.get_default_branch(&git_repo)?; |
| 394 | let branches = if self.all_branches { |
| 395 | self.get_all_branches(&git_repo)? |
| 396 | } else { |
| 397 | vec![self.branch.clone().unwrap_or(default_branch)] |
| 398 | }; |
| 399 | |
| 400 | for branch_name in &branches { |
| 401 | if let Ok(reference) = git_repo.find_branch(branch_name, git2::BranchType::Local) { |
| 402 | if let Some(target) = reference.get().target() { |
| 403 | let count = self.count_commits( |
| 404 | &git_repo, |
| 405 | target, |
| 406 | &HashSet::new(), |
| 407 | !self.all_branches, |
| 408 | )?; |
| 409 | print_info(&format!( |
| 410 | "Would import {} commits from branch '{}'", |
| 411 | count, branch_name |
| 412 | )); |
| 413 | } |
| 414 | } |
| 415 | } |
| 416 | |
| 417 | return Ok(()); |
| 418 | } |
| 419 | |
| 420 | if ensure_git_shadow_excludes(git_repo.path())? { |
| 421 | print_info("Configured Git to ignore Atomic local state."); |
| 422 | } |
| 423 | |
| 424 | // Check if Atomic repository exists in THIS directory (not parent dirs). |
| 425 | // Don't use find_repository_root() — it walks up and might find |
| 426 | // ~/.atomic/ (global config dir) which isn't a repo. |
| 427 | let repo_exists = workdir.join(".atomic").join("pristine.redb").exists(); |
| 428 | let mut repo = if repo_exists { |
| 429 | Repository::open(workdir).map_err(|e| CliError::Internal(e.into()))? |
| 430 | } else { |
| 431 | print_info("Initializing Atomic repository..."); |
| 432 | Repository::init(workdir).map_err(|e| CliError::Internal(e.into()))? |
| 433 | }; |
| 434 | |
| 435 | // Get already imported SHAs for incremental mode |
| 436 | let imported_shas = if self.incremental { |
nothing calls this directly
no test coverage detected