Serialize `remotes` in the legacy `[remotes. ]` map shape so 0.17.x binaries keep parsing the file.
(remotes: &[RemoteConfig], serializer: S)
| 477 | /// Serialize `remotes` in the legacy `[remotes.<name>]` map shape so 0.17.x |
| 478 | /// binaries keep parsing the file. |
| 479 | fn serialize_remotes_compat<S>(remotes: &[RemoteConfig], serializer: S) -> Result<S::Ok, S::Error> |
| 480 | where |
| 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)] |