Please tag a new stable release
The current stable release version 1.0.9 fails with this error message:
$ cargo install cargo-sort
…
$ cargo sort -w
Checking rust...
Finished: Cargo.toml for "rust" has been rewritten
Checking mycrate...
thread 'main' panicked at /Users/shaun.jackman/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cargo-sort-1.0.9/src/sort.rs:113:46:
called `Result::unwrap()` on an `Err` value: TomlError { message: "TOML parse error at line 13, column 6\n |\n13 | serde.workspace = true\n | ^\nUnexpected `.`\nExpected `=`\n" }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
and this issue is fixed on the current main branch. Please tag a new stable release. Thank you!
The workaround is to install cargo-sort from Git:
cargo install --git=https://github.com/DevinR528/cargo-sort --branch=main cargo-sort
@DevinR528 This would be super helpful!
Any progress on this? 👀
Well, after merge: https://github.com/DevinR528/cargo-sort/pull/81 we can close the issue.
@jplatte maybe it's time for new release after upgrade toml_edit?
I read changelog toml_edit, I don't see any breaking changes for this crate: https://github.com/toml-rs/toml/blob/main/crates/toml_edit/CHANGELOG.md#0220---2024-02-05
The upgrade of toml_edit you just did has nothing to do with why the release was yanked. I think it was related to the previous upgrade.
You already observed that running cargo sort on its own repository rewrites a three-line comment to a single line, right? That would need to be fixed before making another release. And I think there are more issues like that. If you are interested in working on fixing those, I can spend some time on creating test cases.
The upgrade of
toml_edityou just did has nothing to do with why the release was yanked. I think it was related to the previous upgrade.You already observed that running
cargo sorton its own repository rewrites a three-line comment to a single line, right? That would need to be fixed before making another release. And I think there are more issues like that. If you are interested in working on fixing those, I can spend some time on creating test cases.
Now I see. Yes, I'll help with the new release. I'll review current test cases and improve them.
If you have test cases it'll be great.
Okay so good news: In Ruma, the project that originally spawned cargo-sort, there seems to be only one thing that regresses formatting with the latest version: A trailing comma on the last item of a multi-line arrays is removed. For the following input:
[package]
name = "cargo-sort-test"
version = "0.1.0"
edition = "2021"
[features]
default = [
"feature-a",
"feature-b",
"feature-c",
"feature-d",
"feature-e",
]
feature-a = []
feature-b = []
feature-c = []
feature-d = []
feature-e = []
the latest cargo sort from main will remove the comma in "feature-e",, whereas v1.0.9 will leave it as-is.
If that bug and the one with cargo sorts own multiline comment are fixed, I'm happy to publish another release :)
Hi @jplatte, Please Publish it. Because Taplo, like cargo-sort, also uses the Toml crate library, Taplo can format a toml file as you expect. If using cargo-sort doesn't meet your expectations, you can use Taplo to process it again without delaying any work at all.
Here is the code slice processed by cargo- sort:
[workspace.package]
homepage = "https://github.com/toml-rs/toml"
repository = "https://github.com/toml-rs/toml"
license = "MIT OR Apache-2.0"
edition = "2021"
rust-version = "1.65" # MSRV
include = ["build.rs", "src/**/*", "Cargo.toml", "Cargo.lock", "LICENSE*", "README.md", "benches/**/*", "examples/**/*", "tests/**/*"]
And Here is the code slice processed by Taplo:
[workspace.package]
homepage = "https://github.com/toml-rs/toml"
repository = "https://github.com/toml-rs/toml"
license = "MIT OR Apache-2.0"
edition = "2021"
rust-version = "1.65" # MSRV
include = [
"build.rs",
"src/**/*",
"Cargo.toml",
"Cargo.lock",
"LICENSE*",
"README.md",
"benches/**/*",
"examples/**/*",
"tests/**/*",
]
Sorry, but no. I'm not going to ship a patch release with known regressions.
Well, I have to install cargo-sort like this:
cargo install cargo-sort --git https://github.com/DevinR528/cargo-sort.git
I hope the command can help other persons.
If that bug and the one with
cargo sorts own multiline comment are fixed, I'm happy to publish another release :)
Is this still the latest or has there been any new discoveries since?
I'll re-check things soon, now that your two PRs merged :)
edit: From one of the tests you added, it seems that this is not fixed. No new discoveries though.
cargo-sort v2.0.0 is out!
Thank you!