mirror of
https://github.com/fabro-sh/fabro.git
synced 2026-12-03 00:47:18 +00:00
Widens the candidate set to include prereleases, picks max semver across stable + prereleases. Falls back to /releases/latest if no parseable non-draft tag is returned. Conflicts with --version. Background auto-upgrade notice remains stable-only. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
3 KiB
3 KiB
fabro upgrade --prerelease — requirements
Problem
fabro upgrade hits GitHub's /releases/latest, which excludes prereleases. Users on a prerelease (e.g. 0.204.0-beta.0) or wanting to opt into betas must supply an exact --version v0.X.Y-alpha.N. There is no channel opt-in.
Goal
Add --prerelease to fabro upgrade so a single invocation picks the highest semver across stable and prereleases.
Behavior
- New bool flag
--prereleaseonfabro upgrade. Conflicts with--version(explicit version already selects any tag). - Scope: only the explicit
fabro upgradecommand. Background auto-check (spawn_upgrade_check/check_and_print_notice) stays stable-only. - Selection when
--prereleaseis set:- Fetch
GET /repos/fabro-sh/fabro/releases(first page, 30 items —ghand HTTP backends). - Drop entries with
draft: trueor an unparseabletag_name. - Pick the max by semver over the remaining set (stable + prereleases together). This means a newer stable beats an older beta;
--prereleasewidens the candidate set, it does not prefer prereleases. - If the filtered set is empty, fall back to the existing stable-latest path (
/releases/latest).
- Fetch
- Downgrade protection unchanged:
- Target < current, no explicit version → bail ("latest release … is older than installed version …, skipping").
- Target == current, no
--force→ "Already on version …".
--dry-run,--force, JSON output, SHA256 verify, atomic swap — all unchanged.
Code touchpoints
lib/crates/fabro-cli/src/args.rs— addprerelease: boolwith#[arg(long, conflicts_with = "version")].lib/crates/fabro-cli/src/commands/upgrade.rs:- New local
ReleaseSummary { tag_name: String, draft: bool, prerelease: bool }(serde). - New
Backend::fetch_releases(&self) -> Result<Vec<ReleaseSummary>>that hits/releasesvia HTTP orgh api repos/{repo}/releases. - New pure
fn pick_latest_tag(releases: &[ReleaseSummary]) -> Option<String>— filters drafts + unparseable tags, returns max-semvertag_name. run_upgrade: whenargs.prerelease, callfetch_releases→pick_latest_tag; onNone, fall back tofetch_latest_release_tag.spawn_upgrade_check/check_and_print_noticeuntouched.
- New local
Tests (unit, no network)
pick_latest_tag:- mixed stable + prerelease, newest is prerelease → picks prerelease.
- mixed stable + prerelease, newest is stable → picks stable.
- all drafts →
None(triggers fallback). - malformed tag (
"weekly-build-3") alongside valid tags → skipped, valid winner returned. - empty input →
None.
- Clap:
fabro upgrade --prerelease --version 0.1.0exits withconflicts_witherror. (ExistingUpgradeArgstests style.)
Out of scope
- Persistent channel config, env var (
FABRO_UPGRADE_CHANNEL),--stableopt-out. - Changing background upgrade notice to include prereleases.
- Docs/changelog updates beyond the
--helpstring (can follow in the same PR as trivial diffs).
Open questions
None.