cargo-semver-checks icon indicating copy to clipboard operation
cargo-semver-checks copied to clipboard

Warn when attempting to use a baseline version higher than the crate's current version

Open obi1kenobi opened this issue 1 year ago • 2 comments

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 avatar May 22 '23 14:05 obi1kenobi

@obi1kenobi I could attempt to give this a shot, can I get some code pointers.

sladyn98 avatar May 22 '23 23:05 sladyn98

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.

obi1kenobi avatar May 23 '23 00:05 obi1kenobi