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

Method run_async

atomic-cli/src/commands/clone/command.rs:291–685  ·  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

289 /// This is the main entry point for the clone operation. It coordinates
290 /// all the steps required to create a local copy of a remote repository.
291 async fn run_async(&self) -> CliResult<()> {
292 // Resolve target path
293 let target_path = resolve_target_path(&self.url, self.path.clone());
294 let display_name = self.get_display_name();
295
296 // Print header
297 println!(
298 "Cloning from {} into {}...",
299 hint(&self.url),
300 style_view(&display_name)
301 );
302 print_blank();
303
304 let guard = if self.into_existing {
305 validate_existing_git_checkout(&target_path)?;
306 None
307 } else {
308 validate_target_path(&target_path)?;
309 std::fs::create_dir_all(&target_path).map_err(|e| CliError::InvalidPath {
310 path: target_path.clone(),
311 source: Some(e),
312 })?;
313 Some(CleanupGuard::new(target_path.clone()))
314 };
315
316 // Initialize repository
317 let spinner = create_spinner("Initializing repository...");
318 let mut repo = Repository::init(&target_path).map_err(|e| {
319 finish_error(&spinner, "Failed to initialize");
320 CliError::Repository(e)
321 })?;
322 finish_success(&spinner, "Repository initialized");
323
324 // Clone must insert remote changes into the requested local view,
325 // rather than whichever default view repository initialization chose.
326 if !repo.view_exists(&self.view).map_err(CliError::Repository)? {
327 repo.create_shared_view(&self.view)
328 .map_err(CliError::Repository)?;
329 }
330 repo.align_to_view(&self.view)
331 .map_err(CliError::Repository)?;
332
333 // Connect to remote
334 let spinner = create_spinner("Connecting to remote...");
335 let config = self.build_remote_config().await;
336 let remote = HttpRemote::with_config(&self.url, config).map_err(|e| {
337 finish_error(&spinner, "Failed to connect");
338 convert_remote_error(e, &self.url)
339 })?;
340 finish_success(&spinner, "Connected");
341
342 // Query remote state
343 let spinner = create_spinner("Querying remote state...");
344 let remote_state = remote.get_state(&self.view).await.map_err(|e| {
345 finish_error(&spinner, "Failed to query state");
346 convert_remote_error(e, &self.url)
347 })?;
348

Callers 1

runMethod · 0.45

Calls 15

resolve_target_pathFunction · 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
print_warningFunction · 0.85
print_hintFunction · 0.85
print_successFunction · 0.85
create_progress_barFunction · 0.85

Tested by

no test coverage detected