mainmatter / cargo-autoinherit

(Auto)DRY for your Rust dependencies
Apache License 2.0
124 stars 8 forks source link

Comments in dependency section of `Cargo.toml` get removed #6

Closed obi1kenobi closed 5 months ago

obi1kenobi commented 5 months ago

The Trustfall project has some meaningful comments in Cargo.toml — some notes on which dependencies are re-exported in our public API vs internal-only, notes on why certain crates and features are enabled, etc.

These comments get wiped out when cargo autoinherit is executed, which is not desirable. The comments get wiped out even if the surrounding dependencies didn't need to change, which is extra unfortunate.

To repro:

git clone git@github.com:obi1kenobi/trustfall.git
cd trustfall
git checkout 5e915a5e3dd6cddb84b9db32f7ab4c8860d7fc4d  # recent `main` branch head
cargo autoinherit

That will produce a diff that includes the following:

diff --git a/Cargo.toml b/Cargo.toml
index 511f0a7..0aa94c7 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -21,8 +21,6 @@ authors = ["Predrag Gruevski <obi1kenobi82@gmail.com>"]
 license = "Apache-2.0"

 [workspace.dependencies]
-# The dependencies below are part of our public API.
-# Bumping a major version here requires our own major version bump.
 anyhow = "1.0.71"
 async-graphql-parser = "7.0"
 async-graphql-value = "7.0"
@@ -30,9 +28,6 @@ serde = "1.0.185"
 serde_json = "1.0.96"
 thiserror = "1.0.30"
 regex = "1.9.1"
-
-# The dependencies below are internal-only.
-# Bumping major versions here should be safe.
 itertools = "0.12.1"
 ron = "0.8.0"
 similar-asserts = "1.4.2"
LukeMathWalker commented 5 months ago

Thanks for testing it out! This should be fixed in 0.1.2 👍🏻

LukeMathWalker commented 5 months ago

While fixing this I spotted another issue, which has been patched in #8. Running cargo-autoinherit on trustfall should work perfectly now!

obi1kenobi commented 5 months ago

Amazing, thank you Luca! This tool is awesome and I'm super glad you built it.