fix: filter prereleases by semver tag instead of GitHub API field#498
Merged
johnstcn merged 1 commit intofix/go-version-checkfrom Mar 25, 2026
Merged
Conversation
|
All contributors have signed the CLA ✍️ ✅ |
…nky promise Replace the GitHub API prerelease boolean check with semver.Version.Prerelease() filtering — because the version string is the source of truth, not metadata. Also: - Extract highestRelease() to eliminate 3x copy-pasted loops - Extract formatVersion() for the repeated Sprintf pattern - Fix pre-existing bug: missing continue after semver parse errors caused stale version from prior iteration to be used - Add table-driven tests for both helpers (there were none before)
2c69b59 to
924d5cc
Compare
There was a problem hiding this comment.
Pull request overview
Updates the scripts/coderversion helper script to select the highest stable release based on SemVer parsing (prerelease suffix detection) rather than relying on GitHub API prerelease metadata, preventing integration tests from selecting non-existent image tags.
Changes:
- Extract
highestRelease()to select the highest non-prerelease SemVer (optionally filtered by minor). - Extract
formatVersion()to consistently formatvMAJOR.MINOR.PATCH(dropping prerelease/build metadata). - Add table-driven tests covering prerelease filtering, minor filtering, and invalid/empty inputs.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| scripts/coderversion/main.go | Refactors version selection into helpers and filters prereleases via SemVer prerelease parsing. |
| scripts/coderversion/main_test.go | Adds unit tests for highestRelease() and formatVersion(). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
matifali
approved these changes
Mar 25, 2026
Member
matifali
left a comment
There was a problem hiding this comment.
Looks good. Thanks for adding tests too. 👍
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
highestRelease()helper: filters prereleases viasemver.Version.Prerelease()instead of GitHub APIprereleasebooleanformatVersion()helper for the repeatedSprintfpatterncontinueaftersemver.NewVersion()errors caused stale version reuseAlternative approach to #497 — operates on the version string (source of truth) rather than relying on GitHub metadata.