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

Method run_async

atomic-cli/src/commands/push/command.rs:315–778  ·  view source on GitHub ↗

Async implementation of the push command.

(&self)

Source from the content-addressed store, hash-verified

313
314 /// Async implementation of the push command.
315 async fn run_async(&self) -> CliResult<()> {
316 // Find and open repository
317 let repo_root = find_repository_root()?;
318 let repo = Repository::open(&repo_root).map_err(CliError::Repository)?;
319
320 // Resolve remote name, URL, and identity hint
321 let (remote_name, remote_url, identity_hint) = self.resolve_remote_url(&repo)?;
322
323 // Determine views
324 let local_view = self.get_local_view(&repo);
325 let remote_view = self.get_remote_view(&local_view);
326 let default_remote_view = "dev".to_string();
327
328 // Print header
329 println!(
330 "Pushing to {} ({})",
331 style_view(&remote_name),
332 hint(&remote_url)
333 );
334
335 // Fail fast if we have no usable credentials for this remote. A push is
336 // a write that always requires auth; without a credential the server's
337 // negotiation endpoints return an ambiguous 404 (private projects are
338 // deliberately masked), which surfaces as a misleading "view not found".
339 // Catching the missing credential here gives the user an accurate,
340 // actionable error instead.
341 crate::commands::auth::check_push_credentials(&remote_url, identity_hint.as_deref())?;
342
343 // Connect to remote
344 let spinner = create_spinner("Connecting to remote...");
345 let config = self
346 .build_remote_config(&remote_url, identity_hint.as_deref())
347 .await;
348 let remote = HttpRemote::with_config(&remote_url, config).map_err(|e| {
349 finish_error(&spinner, "Failed to connect");
350 convert_remote_error(e, &remote_url)
351 })?;
352 finish_success(&spinner, "Connected");
353
354 // Query remote state
355 let spinner = create_spinner("Querying remote state...");
356 let remote_state = remote.get_state(&remote_view).await.map_err(|e| {
357 finish_error(&spinner, "Failed to query state");
358 convert_remote_error(e, &remote_url)
359 })?;
360 finish_success(&spinner, "Got remote state");
361
362 // Get local history
363 let spinner = create_spinner("Loading local history...");
364 let local_entries = repo
365 .log(HistoryOptions::default())
366 .map_err(CliError::Repository)?;
367 finish_success(
368 &spinner,
369 &format!("Loaded {} local changes", local_entries.len()),
370 );
371
372 // Get remote changelist for the target view

Callers 1

runMethod · 0.45

Calls 15

find_repository_rootFunction · 0.85
check_push_credentialsFunction · 0.85
create_spinnerFunction · 0.85
finish_errorFunction · 0.85
finish_successFunction · 0.85
print_blankFunction · 0.85
calculate_push_deltaFunction · 0.85
print_successFunction · 0.85
print_errorFunction · 0.85
print_hintFunction · 0.85
create_progress_barFunction · 0.85
upload_change_smartFunction · 0.85

Tested by

no test coverage detected