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

Method run_remote

atomic-cli/src/commands/view/list.rs:433–487  ·  view source on GitHub ↗

List views on a remote repository. `remote_arg` is the raw `--remote` value: empty means "use the default remote", otherwise it is a configured remote name or a URL.

(&self, remote_arg: &str)

Source from the content-addressed store, hash-verified

431 /// `remote_arg` is the raw `--remote` value: empty means "use the default
432 /// remote", otherwise it is a configured remote name or a URL.
433 fn run_remote(&self, remote_arg: &str) -> CliResult<()> {
434 let repo_root = find_repository_root()?;
435 let repo = Repository::open(&repo_root).map_err(|e| match e {
436 atomic_repository::RepositoryError::NotFound { path } => CliError::RepositoryNotFound {
437 searched_path: path.into(),
438 },
439 other => CliError::Repository(other),
440 })?;
441
442 // Resolve the remote name and URL.
443 let (remote_name, remote_url) = if remote_arg.is_empty() {
444 repo.get_default_remote()
445 .map(|(name, entry)| (name, entry.url))
446 .map_err(CliError::Repository)?
447 } else if remote_arg.contains("://") {
448 (sanitized_remote_label(remote_arg), remote_arg.to_string())
449 } else {
450 let entry = repo
451 .get_remote(remote_arg)
452 .map_err(|_| CliError::RemoteNotFound {
453 name: remote_arg.to_string(),
454 })?;
455 (remote_arg.to_string(), entry.url)
456 };
457
458 if !self.json {
459 println!(
460 "Views on {} ({})",
461 style_view(&remote_name),
462 hint(&remote_url)
463 );
464 }
465
466 let rt = tokio::runtime::Runtime::new().map_err(|e| {
467 CliError::Internal(anyhow::anyhow!("Failed to create async runtime: {}", e))
468 })?;
469
470 let views = rt.block_on(async {
471 let config = HttpRemoteConfig::new()
472 .with_timeout(Duration::from_secs(DEFAULT_TIMEOUT_SECS))
473 .danger_accept_invalid_certs(self.insecure);
474 let config = attach_identity(config, &remote_url, self.identity.as_deref()).await;
475 let remote = HttpRemote::with_config(&remote_url, config)
476 .map_err(|e| CliError::remote_error(e.to_string(), Some(remote_url.clone())))?;
477 // Bare object+ref model: the inventory is composed server-side from
478 // the `.view` objects (GET /refs/views), independent of any
479 // reconciled read-model.
480 remote
481 .list_view_refs()
482 .await
483 .map_err(|e| CliError::remote_error(e.to_string(), Some(remote_url.clone())))
484 })?;
485
486 self.print_remote_views(&views, &remote_name)
487 }
488
489 /// Render the remote view listing.
490 fn print_remote_views(&self, views: &[RemoteViewInfo], remote_name: &str) -> CliResult<()> {

Callers 1

runMethod · 0.80

Calls 14

find_repository_rootFunction · 0.85
openFunction · 0.85
RepositoryClass · 0.85
sanitized_remote_labelFunction · 0.85
attach_identityFunction · 0.85
get_default_remoteMethod · 0.80
list_view_refsMethod · 0.80
print_remote_viewsMethod · 0.80
is_emptyMethod · 0.45
containsMethod · 0.45
get_remoteMethod · 0.45

Tested by

no test coverage detected