Skip to content

fix: skip update when already on latest version (#142)#172

Open
dLo999 wants to merge 1 commit intoDeusData:mainfrom
dLo999:fix/skip-update-when-current
Open

fix: skip update when already on latest version (#142)#172
dLo999 wants to merge 1 commit intoDeusData:mainfrom
dLo999:fix/skip-update-when-current

Conversation

@dLo999
Copy link
Copy Markdown

@dLo999 dLo999 commented Mar 29, 2026

Closes #142

Summary

Adds a version check to the update command that skips the download/install when the binary is already on the latest (or newer) version. Uses the GitHub /releases/latest redirect header to determine the latest tag — no JSON library needed in cli.c.

Changes

  • src/cli/cli.c: Added fetch_latest_tag() helper that follows the GitHub releases redirect via curl -sfI and extracts the tag from the Location: header
  • src/cli/cli.c: Added version comparison block at the start of cbm_cmd_update() using the existing cbm_compare_versions() infrastructure
  • Added --force flag to bypass the version check when needed
  • Network failures produce a warning but don't block the update (graceful degradation)

Behavior

Scenario Output
Already on latest Already up to date (v0.5.7). → exit 0
Ahead of latest (dev build) Already up to date (v0.5.8-dev, ahead of latest v0.5.7). → exit 0
Newer available Update available: v0.5.6 -> v0.5.7 → continues with download
Network failure warning: could not check latest version → continues with download
--force flag Skips check entirely → always downloads
CBM_DOWNLOAD_URL set Skips check (testing path)

Test results

Build: Compiles cleanly on macOS (Apple Clang, arm64) with make -f Makefile.cbm cbm — no extra dependencies needed (zlib ships with Xcode CLT).

Test suite: 2741 tests passed, 0 regressions.

Manual verification (all with --dry-run --standard):

Test Version Result
Already on latest CBM_VERSION=v0.5.7 (== latest) Prints Already up to date (v0.5.7)., exits 0 immediately
Update available CBM_VERSION=v0.5.6 (< latest) Prints Update available: v0.5.6 -> v0.5.7, continues to download
Force bypass CBM_VERSION=v0.5.7 + --force Skips version check, proceeds directly to download

Generated with agent-team via /issue

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Author

@dLo999 dLo999 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Summary

Adds a version check to cbm update that skips download/install when already at latest version. Uses curl redirect header parsing to fetch the latest GitHub release tag, compares with existing cbm_compare_versions() infrastructure. Graceful degradation on network failure.

Findings

  • [nit] src/cli/cli.c:2975 — fetch_latest_tag() uses cbm_popen() with hardcoded URL via shell. NOLINTNEXTLINE bypass is acceptable but should document why for maintainability.
  • [warning] src/cli/cli.c:3024 — getenv("CBM_DOWNLOAD_URL") concurrency bypass is safe in CLI context but comment should note this is only safe because update is never called from multi-threaded code.
  • [question] src/cli/cli.c:3050 — --force flag is not visible in help text in this diff. Is it documented elsewhere (e.g. cbm update --help)?
  • [nit] src/cli/cli.c:2993-3001 — Silent failure on malformed Location header is safe (returns NULL) but a debug warning could aid diagnosis.

CI Status

No CI checks on fork branch. Local testing: 2741 tests passed, 0 regressions (macOS Apple Clang arm64). Manual verification of all 3 scenarios (up-to-date, update available, --force bypass) confirmed working.

Verdict

APPROVE — Implementation is correct, memory-safe, and handles edge cases well. Minor documentation gaps only.

@DeusData DeusData added bug Something isn't working ux/behavior Display bugs, docs, adoption UX labels Mar 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working ux/behavior Display bugs, docs, adoption UX

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update command re-downloads/reinstalls even when already on latest version

2 participants