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

Function sync_resolve_remote

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

5241/// repository, with the same default (the configured default remote, else
5242/// "origin") and the same not-found error.
5243fn sync_resolve_remote(session: &Service, remote: &Option<String>) -> CliResult<(String, String)> {
5244 let response = session.list_remotes(pb::ListRemotesRequest {
5245 repository: Some(session.reference.clone()),
5246 })?;
5247 let name = match remote {
5248 Some(name) if !name.is_empty() => name.clone(),
5249 _ => response
5250 .remotes
5251 .iter()
5252 .find(|remote| remote.default)
5253 .map(|remote| remote.name.clone())
5254 .unwrap_or_else(|| "origin".to_string()),
5255 };
5256 if name.contains("://") {
5257 return Ok((name.clone(), name));
5258 }
5259 match response.remotes.iter().find(|remote| remote.name == name) {
5260 Some(entry) => Ok((name, entry.url.clone())),
5261 None => Err(CliError::RemoteNotFound { name }),
5262 }
5263}
5264
5265/// The client-side auth headers: the SAME attach_identity resolution the
5266/// 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