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

Function push

atomic-cli/src/commands/rpc.rs:5366–5647  ·  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

5364/// the remote-name resolution read, the credential check, and the auth
5365/// header resolution — all config/identity reads, never redb).
5366pub fn push(args: &super::push::Push) -> CliResult<bool> {
5367 use crate::output::{error as print_error_fn, hint, view as style_view};
5368 use crate::output::{hash as style_hash, success as style_success};
5369 let Some(session) = Service::open()? else {
5370 return Ok(false);
5371 };
5372 let (remote_name, remote_url) = sync_resolve_remote(&session, &args.remote)?;
5373
5374 // Print header, fail fast on credentials — the local body's order.
5375 println!(
5376 "Pushing to {} ({})",
5377 style_view(&remote_name),
5378 hint(&remote_url)
5379 );
5380 atomic_remote::auth::check_push_credentials(&remote_url, args.identity.as_deref())?;
5381 let auth_headers = sync_auth_headers(&remote_url, args.identity.as_deref());
5382 stage_line("Connected");
5383
5384 let request = pb::PushChangesRequest {
5385 repository: Some(session.reference.clone()),
5386 meta: request_meta(),
5387 remote: remote_name.clone(),
5388 views: Vec::new(),
5389 expected: None,
5390 to_view: args.to_view.clone(),
5391 from_view: args.from_view.clone(),
5392 dry_run: args.dry_run,
5393 force: args.force,
5394 all: args.all,
5395 insecure: args.insecure,
5396 timeout_secs: args.timeout,
5397 auth_headers: auth_headers.clone(),
5398 remote_url: Some(remote_url.clone()),
5399 identity: args.identity.clone(),
5400 };
5401 let response = match session.push_changes(request) {
5402 Ok(response) => response,
5403 Err(error) => return Err(sync_error_map(error)),
5404 };
5405
5406 // The plan-phase conflict: the local divergence/identity block plus
5407 // the local CliError.
5408 if let Some(conflict) = &response.conflict {
5409 print_error_fn(&format!(
5410 "View '{}' has diverged from the remote",
5411 conflict.view
5412 ));
5413 println!();
5414 if !conflict.identity_mismatch {
5415 if let (Some(local), Some(remote)) = (&conflict.local, &conflict.remote) {
5416 println!(
5417 " Local: {} at {}",
5418 style_view(&local.view),
5419 crate::output::info(&manifest_state_text(&Some(local.clone())))
5420 );
5421 println!(
5422 " Remote: {} at {}",
5423 style_view(&remote.view),

Callers 1

runMethod · 0.50

Calls 15

openFunction · 0.85
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
cloneMethod · 0.45

Tested by

no test coverage detected