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

Function pull

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

`atomic pull` over PullChanges — every form. Same client-side auth model as push; the handler performs the network sync and the applies, and the CLI renders the local pull body's exact lines.

(args: &super::pull::Pull)

Source from the content-addressed store, hash-verified

5690/// model as push; the handler performs the network sync and the applies,
5691/// and the CLI renders the local pull body's exact lines.
5692pub fn pull(args: &super::pull::Pull) -> CliResult<bool> {
5693 use crate::output::{hash as style_hash, hint, success as style_success, view as style_view};
5694 let Some(session) = Service::open()? else {
5695 return Ok(false);
5696 };
5697 let (remote_name, remote_url) = sync_resolve_remote(&session, &args.remote)?;
5698
5699 println!(
5700 "Pulling from {} ({})",
5701 style_view(&remote_name),
5702 hint(&remote_url)
5703 );
5704 let auth_headers = sync_auth_headers(&remote_url, args.identity.as_deref());
5705 stage_line("Connected");
5706
5707 let request = pb::PullChangesRequest {
5708 repository: Some(session.reference.clone()),
5709 meta: request_meta(),
5710 remote: remote_name.clone(),
5711 import_sidecars: true,
5712 to_view: args.to_view.clone(),
5713 from_view: args.from_view.clone(),
5714 dry_run: args.dry_run,
5715 all: args.all,
5716 insecure: args.insecure,
5717 timeout_secs: args.timeout,
5718 identity: args.identity.clone(),
5719 download_only: args.download_only,
5720 auth_headers: auth_headers.clone(),
5721 remote_url: Some(remote_url.clone()),
5722 };
5723 let response = match session.pull_changes(request) {
5724 Ok(response) => response,
5725 Err(error) => return Err(sync_error_map(error)),
5726 };
5727 let Some(report) = response.report else {
5728 return Err(CliError::Internal(anyhow::anyhow!(
5729 "the service returned no pull report"
5730 )));
5731 };
5732 let format_count = super::pull::helpers::format_count;
5733
5734 // The local history + fetch stage lines.
5735 stage_line(&format!(
5736 "Loaded {} local view changes ({} graph objects present)",
5737 report.local_view_changes, report.graph_objects
5738 ));
5739 stage_line(&format!("Got {} remote changes", report.remote_changes));
5740
5741 // State comparison.
5742 println!();
5743 let remote_state_text = match &report.remote_state {
5744 Some(state) if !state.is_empty() => format!(
5745 "at {} ({} {})",
5746 hint(&state[..12.min(state.len())]),
5747 report.remote_changes,
5748 if report.remote_changes == 1 {
5749 "change"

Callers 1

runMethod · 0.50

Calls 15

sync_resolve_remoteFunction · 0.85
sync_auth_headersFunction · 0.85
stage_lineFunction · 0.85
sync_error_mapFunction · 0.85
hintFunction · 0.85
print_warningFunction · 0.85
print_hintFunction · 0.85
print_successFunction · 0.85
print_infoFunction · 0.85
request_metaFunction · 0.70
short_hashFunction · 0.70
openFunction · 0.50

Tested by

no test coverage detected