Skip to content

Improve update release channels#2145

Open
zhuangbiaowei wants to merge 3 commits into
Hmbown:mainfrom
zhuangbiaowei:improve-update-channels
Open

Improve update release channels#2145
zhuangbiaowei wants to merge 3 commits into
Hmbown:mainfrom
zhuangbiaowei:improve-update-channels

Conversation

@zhuangbiaowei
Copy link
Copy Markdown
Contributor

@zhuangbiaowei zhuangbiaowei commented May 26, 2026

Summary

  • add stable and beta release channels for codewhale update
  • skip checksum and binary downloads when the local version is already current or newer
  • add semver-based version comparison and focused tests

Tests

  • cargo fmt
  • cargo test -p codewhale-cli

Greptile Summary

This PR introduces stable and beta release channels for codewhale update, adds semver-based version comparison to skip redundant downloads, and includes focused unit tests for the new logic.

  • ReleaseChannel, FetchedRelease, and ReleaseSource types are added to update.rs; run_update now accepts a beta: bool flag wired to a new --beta CLI argument in lib.rs.
  • fetch_latest_beta_release_from_url scans the /releases?per_page=100 list for the first tag containing "beta"; update_is_needed uses semver to guard against redundant downloads and cross-channel downgrades.
  • The mirror-source path correctly emits a warning when --beta is used, addressing a concern from the previous review thread.

Confidence Score: 5/5

Safe to merge; the channel-switching and downgrade-prevention logic is well-tested and the previous review concerns have been addressed.

The core version-comparison logic in update_is_needed handles the key edge cases (stable-to-beta channel switch, cross-version downgrade prevention, RC vs beta disambiguation) and every case is backed by a unit test. The remaining observations are quality improvements rather than present defects.

crates/cli/src/update.rs — specifically the stable-channel branch of update_is_needed and the mirror-source early-exit path.

Important Files Changed

Filename Overview
crates/cli/src/update.rs Core update logic: adds ReleaseChannel, FetchedRelease, update_is_needed, fetch_latest_beta_release_from_url; previous-thread issues are addressed; stable channel has no prerelease guard; mirror path skips the version check
crates/cli/src/lib.rs Adds UpdateArgs struct with --beta flag and plumbs it into run_update; CLI parsing test added; straightforward change
Cargo.toml Adds semver 1.0.28 as workspace dependency
crates/cli/Cargo.toml Picks up semver from workspace
Cargo.lock Lock file updated for semver dependency

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[codewhale update] -->|--beta flag| B{ReleaseChannel}
    B -->|Stable| C[fetch /releases/latest]
    B -->|Beta| D[fetch /releases?per_page=100]
    C --> E{Mirror env set?}
    D --> E
    E -->|Yes: Mirror| F[release_from_mirror_base_url]
    F --> G{channel == Beta?}
    G -->|Yes| H[Print mirror warning]
    G -->|No| I[Proceed to download]
    H --> I
    E -->|No: GitHub| J[update_is_needed?]
    J -->|No: already current| K[Exit: no download needed]
    J -->|Yes| I
    I --> L[Download checksum manifest]
    L --> M[Download + verify binaries]
    M --> N[Replace binaries atomically]
Loading

Fix All in Codex Fix All in Claude Code Fix All in Cursor

Reviews (3): Last reviewed commit: "Prevent beta update downgrades" | Re-trigger Greptile

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request adds support for updating to beta releases by introducing a --beta flag to the update command, utilizing the semver crate to compare versions and determine if an update is necessary. The review feedback highlights a high-severity issue where the new update_is_needed check unconditionally blocks updates, which breaks the ability to force-reinstall or downgrade when using a custom mirror via environment variables. It is recommended to bypass this check when a custom mirror is configured.

Comment thread crates/cli/src/update.rs Outdated
Comment on lines +41 to +44
if !update_is_needed(current_version, latest_tag)? {
println!("Already up to date; no download needed.");
return Ok(());
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

Unconditionally enforcing the update_is_needed check will break the ability to force-reinstall or downgrade to a specific version when using a custom mirror via DEEPSEEK_TUI_RELEASE_BASE_URL (and DEEPSEEK_TUI_VERSION).\n\nWhen a mirror is configured, the tool should bypass the version comparison check so that the user-specified version is always downloaded and installed. We should only enforce the update_is_needed check when fetching releases directly from GitHub.

    if release_base_url_from_env().is_none() && !update_is_needed(current_version, latest_tag)? {\n        println!("Already up to date; no download needed.");\n        return Ok(());\n    }

Comment thread crates/cli/src/update.rs Outdated
Comment thread crates/cli/src/update.rs
Comment thread crates/cli/src/update.rs Outdated
Comment thread crates/cli/src/update.rs
Comment thread crates/cli/src/update.rs
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