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

Function pull

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

5650/// model as push; the handler performs the network sync and the applies,
5651/// and the CLI renders the local pull body's exact lines.
5652pub fn pull(args: &super::pull::Pull) -> CliResult<bool> {
5653 use crate::output::{hash as style_hash, hint, success as style_success, view as style_view};
5654 let Some(session) = Service::open()? else {
5655 return Ok(false);
5656 };
5657 let (remote_name, remote_url) = sync_resolve_remote(&session, &args.remote)?;
5658
5659 println!(
5660 "Pulling from {} ({})",
5661 style_view(&remote_name),
5662 hint(&remote_url)
5663 );
5664 let auth_headers = sync_auth_headers(&remote_url, args.identity.as_deref());
5665 stage_line("Connected");
5666
5667 let request = pb::PullChangesRequest {
5668 repository: Some(session.reference.clone()),
5669 meta: request_meta(),
5670 remote: remote_name.clone(),
5671 import_sidecars: true,
5672 to_view: args.to_view.clone(),
5673 from_view: args.from_view.clone(),
5674 dry_run: args.dry_run,
5675 all: args.all,
5676 insecure: args.insecure,
5677 timeout_secs: args.timeout,
5678 identity: args.identity.clone(),
5679 download_only: args.download_only,
5680 auth_headers: auth_headers.clone(),
5681 remote_url: Some(remote_url.clone()),
5682 };
5683 let response = match session.pull_changes(request) {
5684 Ok(response) => response,
5685 Err(error) => return Err(sync_error_map(error)),
5686 };
5687 let Some(report) = response.report else {
5688 return Err(CliError::Internal(anyhow::anyhow!(
5689 "the service returned no pull report"
5690 )));
5691 };
5692 let format_count = super::pull::helpers::format_count;
5693
5694 // The local history + fetch stage lines.
5695 stage_line(&format!(
5696 "Loaded {} local view changes ({} graph objects present)",
5697 report.local_view_changes, report.graph_objects
5698 ));
5699 stage_line(&format!("Got {} remote changes", report.remote_changes));
5700
5701 // State comparison.
5702 println!();
5703 let remote_state_text = match &report.remote_state {
5704 Some(state) if !state.is_empty() => format!(
5705 "at {} ({} {})",
5706 hint(&state[..12.min(state.len())]),
5707 report.remote_changes,
5708 if report.remote_changes == 1 {
5709 "change"

Callers 1

runMethod · 0.50

Calls 15

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

Tested by

no test coverage detected