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

Method run

atomic-cli/src/commands/git/import.rs:392–616  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 15

print_infoFunction · 0.85
print_hintFunction · 0.85
print_warningFunction · 0.85
reindex_working_copyFunction · 0.85
print_successFunction · 0.85
current_git_branchFunction · 0.85
build_content_indexFunction · 0.85
get_default_branchMethod · 0.80
get_all_branchesMethod · 0.80
count_commitsMethod · 0.80

Tested by

no test coverage detected