From 927faedf38a4f9263a96ee6ac971e3ca513e8e49 Mon Sep 17 00:00:00 2001 From: Ethan Brierley Date: Sat, 18 May 2024 22:52:06 +0100 Subject: [PATCH] fix: superfluous super-table `[patch]` generated fixes #21 --- src/lib.rs | 8 ++++++-- tests/tests.rs | 2 -- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index da4986b..159582e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -32,9 +32,10 @@ pub fn run(working_dir: &Path, args: Args) -> anyhow::Result<()> { let project_manifest_table = project_manifest_toml.as_table_mut(); - let project_patch_table = create_subtable(project_manifest_table, "patch")?; + let project_patch_table = create_subtable(project_manifest_table, "patch", true)?; - let project_patch_overrides_table = create_subtable(project_patch_table, DEFAULT_REGISTRY)?; + let project_patch_overrides_table = + create_subtable(project_patch_table, DEFAULT_REGISTRY, false)?; let Ok(new_patch) = format!("{{ path = \"{}\" }}", args.path).parse::() else { todo!("We haven't escaped the path so we can't be sure this will parse") @@ -81,6 +82,7 @@ fn get_project_dependencies( fn create_subtable<'a>( table: &'a mut toml_edit::Table, name: &str, + dotted: bool, ) -> anyhow::Result<&'a mut toml_edit::Table> { let existing = &mut table[name]; @@ -96,6 +98,8 @@ fn create_subtable<'a>( bail!("{name} already exists but is not a table") }; + subtable.set_dotted(dotted); + Ok(subtable) } diff --git a/tests/tests.rs b/tests/tests.rs index f11dc5d..ec71fca 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -68,8 +68,6 @@ fn patch_exists() { name = "package-name" path = "src/main.rs" - [patch] - [patch.crates-io] anyhow = { path = "anyhow" } '''