Skip to content

Alpha and beta releases sort above the final release #58

Description

@roxblnfk

Description

ReleasesCollection::sortByVersion() ranks alpha and beta pre-releases above the final release of the same version. Sorting v2024.1.0-alpha.1, v2024.1.0, v2024.1.0-beta.1, v2024.1.0-rc.1 gives:

v2024.1.0-beta.1
v2024.1.0-alpha.1
v2024.1.0
v2024.1.0-rc.1

Expected: v2024.1.0, v2024.1.0-rc.1, v2024.1.0-beta.1, v2024.1.0-alpha.1.

get-binary and download-protoc-binary install the first release of the sorted list that passes the stability filter. With --stability=beta (or lower) they pick the beta over the final release that is already out.

comparisonVersionString() replaces -<stability> with .<weight>.. v2024.1.0-beta.1 therefore compares as v2024.1.0.2..1, and version_compare() ranks it above v2024.1.0 because it has more numeric parts. Lower-case -rc tags are left untouched (the stability is RC), so they happen to sort correctly. Upper-case -RC tags have the same problem as beta and alpha. #2 was about the order among pre-releases.

Steps to reproduce

  1. Remove #[Skip] from ReleasesCollectionTest::sortByVersionPutsPreReleasesBelowFinalRelease.
  2. Run vendor/bin/testo --filter=sortByVersionPutsPreReleasesBelowFinalRelease.

Additional context

The release lookup may be replaced by DLoad in #49, in which case this code goes away.

Activity

  1. roxblnfk commented on Oct 9, 2026

    @roxblnfk
    MemberAuthor

    One more consequence of the same comparisonVersionString() logic: lower-case -rc tags are left untouched while -beta is rewritten into extra numeric parts, so v3.5.0-beta.1 also ranks above v3.5.0-rc.1. With --stability=beta and both pre-releases published, rr get installs the older beta instead of the RC.

    The acceptance tests in #66 cover it in VersionSelectionTest::prefersReleaseCandidateOverOlderBeta (skipped with a reference here). The lower-case --stability=rc part of that test is #67.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions