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

Method run_async

atomic-cli/src/commands/clone/command.rs:948–1413  ·  view source on GitHub ↗

Async implementation of the clone command. This is the main entry point for the clone operation. It coordinates all the steps required to create a local copy of a remote repository.

(&self)

Source from the content-addressed store, hash-verified

946 /// This is the main entry point for the clone operation. It coordinates
947 /// all the steps required to create a local copy of a remote repository.
948 async fn run_async(&self) -> CliResult<()> {
949 // CB-10B: the Git-transport bootstrap (RFC §7.3/§8.6). Explicit
950 // `--git`, `.git`-suffixed URLs, scp-like `git@…` forms, and existing
951 // local Git repositories clone via Git and bootstrap through the
952 // shared binding-first anchoring; everything else stays on the
953 // atomic-api path below.
954 let provisional_target = resolve_target_path(&self.url, self.path.clone());
955 if self.git || crate::commands::git::bootstrap::is_git_url(&self.url, &provisional_target) {
956 return self.run_git_bootstrap(&provisional_target);
957 }
958
959 // Resolve target path
960 let target_path = resolve_target_path(&self.url, self.path.clone());
961 let display_name = self.get_display_name();
962
963 // Print header
964 println!(
965 "Cloning from {} into {}...",
966 hint(&self.url),
967 style_view(&display_name)
968 );
969 print_blank();
970
971 // Explicit bootstrap boundary: transport runs before any persistent
972 // working copy exists, so this boundary holds no working-copy ID and
973 // none is fabricated.
974 let bootstrap = CloneBootstrapBoundary::begin(target_path.clone());
975 debug_assert!(bootstrap.working_copy().is_none());
976 drop(bootstrap);
977
978 let guard = if self.into_existing {
979 validate_existing_git_checkout(&target_path)?;
980 None
981 } else {
982 validate_target_path(&target_path)?;
983 std::fs::create_dir_all(&target_path).map_err(|e| CliError::InvalidPath {
984 path: target_path.clone(),
985 source: Some(e),
986 })?;
987 Some(CleanupGuard::new(target_path.clone()))
988 };
989
990 // Initialize repository
991 let spinner = create_spinner("Initializing repository...");
992 let mut repo = Repository::init(&target_path).map_err(|e| {
993 finish_error(&spinner, "Failed to initialize");
994 CliError::Repository(e)
995 })?;
996 finish_success(&spinner, "Repository initialized");
997
998 // From here the clone is repository-local (view alignment,
999 // materialization): enter the shared workspace transaction and retain
1000 // its authority for the whole body. A fresh clone is anchored to the
1001 // working-copy record, never to current_view.
1002 let workspace =
1003 enter_workspace(&mut repo, WorkspaceTxnMode::Reconcile).inspect_err(|error| {
1004 if let Some(guard) = guard.as_ref() {
1005 log::info!("clone cleanup guard engaged after workspace refusal");

Callers 1

runMethod · 0.45

Calls 15

resolve_target_pathFunction · 0.85
is_git_urlFunction · 0.85
print_blankFunction · 0.85
validate_target_pathFunction · 0.85
create_spinnerFunction · 0.85
finish_errorFunction · 0.85
RepositoryClass · 0.85
finish_successFunction · 0.85
reconcile_after_fetchFunction · 0.85
print_warningFunction · 0.85
print_successFunction · 0.85

Tested by

no test coverage detected