fix: skip update when already on latest version (#142)#172
Open
dLo999 wants to merge 1 commit intoDeusData:mainfrom
Open
fix: skip update when already on latest version (#142)#172dLo999 wants to merge 1 commit intoDeusData:mainfrom
dLo999 wants to merge 1 commit intoDeusData:mainfrom
Conversation
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
dLo999
commented
Mar 29, 2026
Author
dLo999
left a comment
There was a problem hiding this comment.
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()usescbm_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 —
--forceflag 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.
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.
Closes #142
Summary
Adds a version check to the
updatecommand that skips the download/install when the binary is already on the latest (or newer) version. Uses the GitHub/releases/latestredirect header to determine the latest tag — no JSON library needed in cli.c.Changes
src/cli/cli.c: Addedfetch_latest_tag()helper that follows the GitHub releases redirect viacurl -sfIand extracts the tag from theLocation:headersrc/cli/cli.c: Added version comparison block at the start ofcbm_cmd_update()using the existingcbm_compare_versions()infrastructure--forceflag to bypass the version check when neededBehavior
Already up to date (v0.5.7).→ exit 0Already up to date (v0.5.8-dev, ahead of latest v0.5.7).→ exit 0Update available: v0.5.6 -> v0.5.7→ continues with downloadwarning: could not check latest version→ continues with download--forceflagCBM_DOWNLOAD_URLsetTest 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):CBM_VERSION=v0.5.7(== latest)Already up to date (v0.5.7)., exits 0 immediatelyCBM_VERSION=v0.5.6(< latest)Update available: v0.5.6 -> v0.5.7, continues to downloadCBM_VERSION=v0.5.7+--forceGenerated with agent-team via /issue