Skip to content

Commit

Permalink
refactor!: Stop using implicit cargo metadata
Browse files Browse the repository at this point in the history
Previously, `Cargo.toml` files were loaded in a way that introduced implicit
metadata, which could cause incorrect behavior in manifests updated by *bomper*.
This commit removes the unnecessary metadata and ensures that *bomper*
will not write excess data when overwriting files.
  • Loading branch information
justinrubek committed Apr 2, 2023
1 parent ae8d311 commit ad4173f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
4 changes: 3 additions & 1 deletion src/replacers/cargo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,10 @@ impl Replacer for CargoReplacer {
// Update each package's Cargo.toml with the new version
for package in packages {
let cargo_toml_path = package.manifest_path;
let cargo_toml_content = std::fs::read(&cargo_toml_path)?;

let mut cargo_toml = cargo_toml::Manifest::from_path(&cargo_toml_path)?;
let mut cargo_toml = cargo_toml::Manifest::from_slice(&cargo_toml_content)?;
// let mut cargo_toml = cargo_toml::Manifest::from_path(&cargo_toml_path)?;

let toml_package = match cargo_toml.package {
Some(ref mut package) => package,
Expand Down
10 changes: 0 additions & 10 deletions src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,6 @@ name = "package1"
edition = "2018"
version = "0.1.0"
[[bin]]

This comment has been minimized.

Copy link
@justinrubek

justinrubek Apr 2, 2023

Author Owner

The tests were written to include the implicit data, but this is no longer needed

path = "src/main.rs"
name = "package1"
required-features = []
[dependencies]
package2 = "0.1.0"
package3 = "0.1.0"
Expand All @@ -184,11 +179,6 @@ version = "0.2.0"
[dependencies]
package2 = "0.1.0"
package3 = "0.1.0"
[[bin]]
path = "src/main.rs"
name = "package1"
required-features = []
"#;

jail.create_file(
Expand Down

0 comments on commit ad4173f

Please sign in to comment.