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

Function sync_resolve_remote

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

Resolve the remote name + URL through the service layer's ListRemotes read — the same domain lookup the local bodies perform over the repository, with the same default (the configured default remote, else "origin") and the same not-found error.

(session: &Service, remote: &Option<String>)

Source from the content-addressed store, hash-verified

5281/// repository, with the same default (the configured default remote, else
5282/// "origin") and the same not-found error.
5283fn sync_resolve_remote(session: &Service, remote: &Option<String>) -> CliResult<(String, String)> {
5284 let response = session.list_remotes(pb::ListRemotesRequest {
5285 repository: Some(session.reference.clone()),
5286 })?;
5287 let name = match remote {
5288 Some(name) if !name.is_empty() => name.clone(),
5289 _ => response
5290 .remotes
5291 .iter()
5292 .find(|remote| remote.default)
5293 .map(|remote| remote.name.clone())
5294 .unwrap_or_else(|| "origin".to_string()),
5295 };
5296 if name.contains("://") {
5297 return Ok((name.clone(), name));
5298 }
5299 match response.remotes.iter().find(|remote| remote.name == name) {
5300 Some(entry) => Ok((name, entry.url.clone())),
5301 None => Err(CliError::RemoteNotFound { name }),
5302 }
5303}
5304
5305/// The client-side auth headers: the SAME attach_identity resolution the
5306/// local bodies run (identity store + config reads + token minting — none

Callers 3

pushFunction · 0.85
pullFunction · 0.85
query_reindexFunction · 0.85

Calls 5

list_remotesMethod · 0.45
cloneMethod · 0.45
is_emptyMethod · 0.45
iterMethod · 0.45
containsMethod · 0.45

Tested by

no test coverage detected