Skip to content

Commit

Permalink
fix: superfluous super-table [patch] generated
Browse files Browse the repository at this point in the history
fixes #21
  • Loading branch information
eopb committed May 19, 2024
1 parent e338456 commit 927faed
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 6 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<toml_edit::Item>() else {
todo!("We haven't escaped the path so we can't be sure this will parse")
Expand Down Expand Up @@ -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];

Expand All @@ -96,6 +98,8 @@ fn create_subtable<'a>(
bail!("{name} already exists but is not a table")
};

subtable.set_dotted(dotted);

Ok(subtable)
}

Expand Down
2 changes: 0 additions & 2 deletions tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ fn patch_exists() {
name = "package-name"
path = "src/main.rs"
[patch]
[patch.crates-io]
anyhow = { path = "anyhow" }
'''
Expand Down

0 comments on commit 927faed

Please sign in to comment.