From 14d28ac9feca3548bf427a30819872cb9b8f10f9 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Fri, 12 Apr 2024 15:21:21 -0500 Subject: [PATCH] refactor(config): Consistently use kebab-case This shouldn't change the behavior but makes it safer if - We add new fields where it will matter - Copy/paste these for new structs I did not change things related to the Index because we are already stuck with that case (whether we want it or not) --- src/cargo/ops/cargo_new.rs | 1 + src/cargo/sources/directory.rs | 1 + src/cargo/sources/registry/mod.rs | 1 + src/cargo/util/context/mod.rs | 5 ++++- 4 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/cargo/ops/cargo_new.rs b/src/cargo/ops/cargo_new.rs index ca316146266a..f349395b55ff 100644 --- a/src/cargo/ops/cargo_new.rs +++ b/src/cargo/ops/cargo_new.rs @@ -131,6 +131,7 @@ impl NewOptions { } #[derive(Deserialize)] +#[serde(rename_all = "kebab-case")] struct CargoNewConfig { #[deprecated = "cargo-new no longer supports adding the authors field"] #[allow(dead_code)] diff --git a/src/cargo/sources/directory.rs b/src/cargo/sources/directory.rs index f853391a5615..33c0f8d97a0c 100644 --- a/src/cargo/sources/directory.rs +++ b/src/cargo/sources/directory.rs @@ -70,6 +70,7 @@ pub struct DirectorySource<'gctx> { /// The file name is simply `.cargo-checksum.json`. The checksum algorithm as /// of now is SHA256. #[derive(Deserialize)] +#[serde(rename_all = "kebab-case")] struct Checksum { /// Checksum of the package. Normally it is computed from the `.crate` file. package: Option, diff --git a/src/cargo/sources/registry/mod.rs b/src/cargo/sources/registry/mod.rs index b1ef55d243b3..93e35abeff8a 100644 --- a/src/cargo/sources/registry/mod.rs +++ b/src/cargo/sources/registry/mod.rs @@ -227,6 +227,7 @@ pub const CRATES_IO_DOMAIN: &str = "crates.io"; /// The content inside `.cargo-ok`. /// See [`RegistrySource::unpack_package`] for more. #[derive(Deserialize, Serialize)] +#[serde(rename_all = "kebab-case")] struct LockMetadata { /// The version of `.cargo-ok` file v: u32, diff --git a/src/cargo/util/context/mod.rs b/src/cargo/util/context/mod.rs index f38fbd3df536..115cac968938 100644 --- a/src/cargo/util/context/mod.rs +++ b/src/cargo/util/context/mod.rs @@ -2514,6 +2514,7 @@ impl<'de> Deserialize<'de> for SslVersionConfig { } #[derive(Clone, Debug, Deserialize, PartialEq)] +#[serde(rename_all = "kebab-case")] pub struct SslVersionConfigRange { pub min: Option, pub max: Option, @@ -2644,6 +2645,7 @@ impl BuildTargetConfig { } #[derive(Deserialize, Default)] +#[serde(rename_all = "kebab-case")] pub struct TermConfig { pub verbose: Option, pub quiet: Option, @@ -2656,13 +2658,14 @@ pub struct TermConfig { } #[derive(Debug, Default, Deserialize)] +#[serde(rename_all = "kebab-case")] pub struct ProgressConfig { pub when: ProgressWhen, pub width: Option, } #[derive(Debug, Default, Deserialize)] -#[serde(rename_all = "lowercase")] +#[serde(rename_all = "kebab-case")] pub enum ProgressWhen { #[default] Auto,