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

Function serialize_remotes_compat

atomic-config/src/lib.rs:479–498  ·  view source on GitHub ↗

Serialize `remotes` in the legacy `[remotes. ]` map shape so 0.17.x binaries keep parsing the file.

(remotes: &[RemoteConfig], serializer: S)

Source from the content-addressed store, hash-verified

477/// Serialize `remotes` in the legacy `[remotes.<name>]` map shape so 0.17.x
478/// binaries keep parsing the file.
479fn serialize_remotes_compat<S>(remotes: &[RemoteConfig], serializer: S) -> Result<S::Ok, S::Error>
480where
481 S: serde::Serializer,
482{
483 use serde::ser::SerializeMap as _;
484 let mut map = serializer.serialize_map(Some(remotes.len()))?;
485 for remote in remotes {
486 let mut entry = serde_json::Map::new();
487 entry.insert("url".into(), serde_json::Value::String(remote.url.clone()));
488 entry.insert("default".into(), serde_json::Value::Bool(false));
489 if let Some(channel) = &remote.default_channel {
490 entry.insert(
491 "default_channel".into(),
492 serde_json::Value::String(channel.clone()),
493 );
494 }
495 map.serialize_entry(&remote.name, &serde_json::Value::Object(entry))?;
496 }
497 map.end()
498}
499
500/// Repository-specific configuration
501#[derive(Debug, Clone, Serialize, Deserialize, Default)]

Callers

nothing calls this directly

Calls 4

endMethod · 0.80
lenMethod · 0.45
insertMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected