Repository navigation
fix(update): compare versions semantically, not as strings - #729
Conversation
LeMyst
left a comment
There was a problem hiding this comment.
Thanks. This is correct:
semver1.x is already inCargo.lockthroughself_update, so no new crate version comes in. It is optional, behindself-update.- Both comparisons in
update.rsare switched, andcook doctor's update check goes throughcheck_for_updates, so it's fixed too. - Pre-release versions compare correctly, and an unparseable version falls back to the old order.
An option to consider: self_update::version::bump_is_greater(current, other) -> Result<bool> does the same comparison without a direct dependency. That would also avoid a Cargo.toml conflict.
Conflicts:
- With #728 in
src/update.rs: trivial, adjacent lines. - With #650, which is still open: both add to the
self-updatefeature line (dep:sha2there,dep:semverhere), and both add a#[cfg(test)] mod testsat the end ofupdate.rs, which must become one module. #650 still compares versions as strings, so this fix is still needed on top of it.
🤖 Analysis and recommendations made by Claude (Anthropic's AI assistant), posted on behalf of @LeMyst.
`cook update` and `cook doctor`'s version check ordered versions lexicographically, so `0.38.9 >= 0.38.10` and the first release across a digit-width boundary would report "already on the latest version". Compare with `semver::Version` (already in the tree via `self_update`), keeping the old string ordering only for unparseable values. Closes #718
clippy::items_after_test_module denies items below the tests block; get_target_triple sat under it.
ba0c71b to
5854628
Compare
|
Thanks for the rebase. I checked it again on 5854628:
It merges cleanly with One heads-up about #650, which also rewrites 🤖 Analysis and recommendations made by Claude (Anthropic's AI assistant), posted on behalf of @LeMyst. |
|
Thanks — and since this landed first, the |
Closes #718
cook updateandcook doctor's update check compared version strings lexicographically:"0.38.9" >= "0.38.10", so crossing a digit-width boundary would hide the newer release. Both sites now go throughversion_is_newer, which parses withsemver::Version(already in the dependency tree viaself_update, now an optional dep of theself-updatefeature) and keeps the previous string ordering only as a fallback for unparseable values.Test plan
cargo test update::— new unit tests cover the 0.38.9→0.38.10 boundary, equality, and the unparseable fallback