cargo-semver-checks
cargo-semver-checks copied to clipboard
Warn when attempting to use a baseline version higher than the crate's current version
Users might accidentally command that a baseline version higher than the crate's current version is used, which is almost never what one actually wants. This can often happen when --workspace
and --baseline-version
are used together in a workspace that doesn't version all its crates in lockstep — for example here.
We should detect that we're about to check a crate whose local version is higher than the baseline version, and emit a warning.
@obi1kenobi I could attempt to give this a shot, can I get some code pointers.
This is the bit where the current crate's version is known, and where the baseline (the version we're comparing against) is about to have its rustdoc data generated. An invalid baseline version would fail a few lines after that: https://github.com/obi1kenobi/cargo-semver-checks/blob/main/src/lib.rs#L600-L607
The GlobalConfig
argument has a shell_warn()
method that we use for printing warnings.
You may need to do some refactoring and plumbing to get all the data in the right places. Right now the method that generates the rustdoc JSON data doesn't know if an exact version was specified for the baseline. Perhaps it should? Or perhaps we can refactor some of the steps out from there and tweak the abstraction.
So just take a look around and figure out what you think is best. I'm happy to assist in whatever way is best — just ask. Happy to talk things over before you start implementing, or look at draft PRs, or whatever else you need.