Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Alpha and beta releases sort above the final release

Open Beginner friendly
#58 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
74/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
php
Domain
cli

Research direction

The sort lives in comparisonVersionString() in src/Repository/ReleasesCollection.php, which rewrites -beta.1 style suffixes into numeric parts that version_compare() then misranks. Start by removing #[Skip] from ReleasesCollectionTest::sortByVersionPutsPreReleasesBelowFinalRelease and running vendor/bin/testo --filter=sortByVersionPutsPreReleasesBelowFinalRelease. Done when that test passes and final releases sort above rc, beta and alpha, including upper-case -RC. Check #49 first, since replacing the release lookup could remove this code.

Written by the indexing model from the issue text.

Description

bug

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.

Dominant language
PHP
Stars
30
Forks
15
Avg merge
45m
Merged PRs (30d)
11

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from roadrunner-php/cli

All issues in roadrunner-php/cli

Similar issues

More PHP issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.