Skip to content

fix(cli): skip self-update download prompt when already on the latest version#101

Merged
sunerpy merged 1 commit into
mainfrom
fix/self-update-skip-when-current
Jul 1, 2026
Merged

fix(cli): skip self-update download prompt when already on the latest version#101
sunerpy merged 1 commit into
mainfrom
fix/self-update-skip-when-current

Conversation

@sunerpy

@sunerpy sunerpy commented Jul 1, 2026

Copy link
Copy Markdown
Owner

Problem

codegraph self-update (no --tag, no --force) resolved the latest release and called updater.update() unconditionally, so a binary already on the newest version STILL entered the self_update crate'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.

Checking current version... v0.23.0
Looking for tag: v0.23.0
  * New exe release: codegraph-0.23.0-...   # same version!
Do you want to continue? [Y/n]

Fix

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 already uses) and early-return codegraph <ver> is already up to date BEFORE any download/prompt when: no explicit --tag, --force not passed, and the latest release is not newer than current.

  • --force still reinstalls (its doc: "Reinstall even if already on the latest version")
  • --tag <v> still installs the requested version verbatim
  • --check is unchanged

Verification

  • make ci green (fmt + clippy -D warnings + test + guardrail); git diff reference/ empty
  • New unit tests: skips_when_current_equals_latest_and_not_forced, force_never_skips, newer_latest_never_skips, explicit_tag_never_skips
  • Hands-on QA on the built binary (currently v0.23.0 = latest): codegraph 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 --check still reports up-to-date

… 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.
@sunerpy sunerpy merged commit 2244c62 into main Jul 1, 2026
4 checks passed
@sunerpy sunerpy deleted the fix/self-update-skip-when-current branch July 1, 2026 05:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant