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

Function push

atomic-cli/src/commands/rpc.rs:5406–5687  ·  view source on GitHub ↗

`atomic push` over PushChanges — every form. The handler performs the network sync end to end and returns the structured report; the CLI renders the local push body's exact lines (the client-side pieces are the remote-name resolution read, the credential check, and the auth header resolution — all config/identity reads, never redb).

(args: &super::push::Push)

Source from the content-addressed store, hash-verified

5404/// the remote-name resolution read, the credential check, and the auth
5405/// header resolution — all config/identity reads, never redb).
5406pub fn push(args: &super::push::Push) -> CliResult<bool> {
5407 use crate::output::{error as print_error_fn, hint, view as style_view};
5408 use crate::output::{hash as style_hash, success as style_success};
5409 let Some(session) = Service::open()? else {
5410 return Ok(false);
5411 };
5412 let (remote_name, remote_url) = sync_resolve_remote(&session, &args.remote)?;
5413
5414 // Print header, fail fast on credentials — the local body's order.
5415 println!(
5416 "Pushing to {} ({})",
5417 style_view(&remote_name),
5418 hint(&remote_url)
5419 );
5420 atomic_remote::auth::check_push_credentials(&remote_url, args.identity.as_deref())?;
5421 let auth_headers = sync_auth_headers(&remote_url, args.identity.as_deref());
5422 stage_line("Connected");
5423
5424 let request = pb::PushChangesRequest {
5425 repository: Some(session.reference.clone()),
5426 meta: request_meta(),
5427 remote: remote_name.clone(),
5428 views: Vec::new(),
5429 expected: None,
5430 to_view: args.to_view.clone(),
5431 from_view: args.from_view.clone(),
5432 dry_run: args.dry_run,
5433 force: args.force,
5434 all: args.all,
5435 insecure: args.insecure,
5436 timeout_secs: args.timeout,
5437 auth_headers: auth_headers.clone(),
5438 remote_url: Some(remote_url.clone()),
5439 identity: args.identity.clone(),
5440 };
5441 let response = match session.push_changes(request) {
5442 Ok(response) => response,
5443 Err(error) => return Err(sync_error_map(error)),
5444 };
5445
5446 // The plan-phase conflict: the local divergence/identity block plus
5447 // the local CliError.
5448 if let Some(conflict) = &response.conflict {
5449 print_error_fn(&format!(
5450 "View '{}' has diverged from the remote",
5451 conflict.view
5452 ));
5453 println!();
5454 if !conflict.identity_mismatch {
5455 if let (Some(local), Some(remote)) = (&conflict.local, &conflict.remote) {
5456 println!(
5457 " Local: {} at {}",
5458 style_view(&local.view),
5459 crate::output::info(&manifest_state_text(&Some(local.clone())))
5460 );
5461 println!(
5462 " Remote: {} at {}",
5463 style_view(&remote.view),

Callers 2

runMethod · 0.50
issuesFunction · 0.50

Calls 15

sync_resolve_remoteFunction · 0.85
check_push_credentialsFunction · 0.85
sync_auth_headersFunction · 0.85
stage_lineFunction · 0.85
sync_error_mapFunction · 0.85
print_hintFunction · 0.85
print_warningFunction · 0.85
print_successFunction · 0.85
request_metaFunction · 0.70
short_hashFunction · 0.70
openFunction · 0.50
cloneMethod · 0.45

Tested by

no test coverage detected