fix(cli): skip self-update download prompt when already on the latest version#101
Merged
Merged
Conversation
… version `codegraph self-update` (no --tag, no --force) resolved the latest release and called updater.update() unconditionally, so an up-to-date binary still entered the self_update crate's interactive "download/replace … [Y/n]" flow even though the target version equalled the current one. Add a pure `should_skip_update(current, latest, force, has_explicit_tag)` helper (reusing self_update::version::bump_is_greater, the same comparator the --check branch uses) and early-return "codegraph <ver> is already up to date" before any download/prompt when no explicit tag was given, --force was not passed, and the latest release is not newer. --force still reinstalls, --tag still installs the requested version verbatim, and --check is unchanged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
codegraph self-update(no--tag, no--force) resolved the latest release and calledupdater.update()unconditionally, so a binary already on the newest version STILL entered theself_updatecrate's interactive "the existing binary will be replaced. Do you want to continue? [Y/n]" flow — even though the target version equalled the current one.Fix
Add a pure
should_skip_update(current, latest, force, has_explicit_tag)helper (reusingself_update::version::bump_is_greater— the same comparator the--checkbranch already uses) and early-returncodegraph <ver> is already up to dateBEFORE any download/prompt when: no explicit--tag,--forcenot passed, and the latest release is not newer than current.--forcestill reinstalls (its doc: "Reinstall even if already on the latest version")--tag <v>still installs the requested version verbatim--checkis unchangedVerification
make cigreen (fmt + clippy -D warnings + test + guardrail);git diff reference/emptyskips_when_current_equals_latest_and_not_forced,force_never_skips,newer_latest_never_skips,explicit_tag_never_skipscodegraph self-update→ prints "codegraph 0.23.0 is already up to date" and exits 0 with no[Y/n]prompt and no download;self-update --checkstill reports up-to-date