Repository navigation
Add support for rc and beta versions in go.mod file - #701
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds support for matching Go versions in rc and beta formats (e.g., 1.14rc1, 1.18beta1) when specified as version inputs. It extends both the regex pattern for parsing go.mod/go.work files and the version matching logic in findMatch().
Key changes:
- Enhanced the regex in
parseGoVersionFile()to recognize beta/rc suffixes in version strings - Modified
findMatch()to perform a strict equality check usingmakeSemver()before falling back tosemver.satisfies(), enabling direct matching of Go-format version specs like1.14rc1 - Added a test case to verify that
findMatch()correctly resolves Go-format rc version specs
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/installer.ts | Extended regex pattern to match beta/rc versions in go directive; added strict equality check in findMatch() for Go-format version specs |
| dist/setup/index.js | Compiled distribution file reflecting the source changes |
| tests/setup-go.test.ts | Added test case for finding pre-release versions using Go version format (1.14rc1) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 3 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 4 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
6b239de to
9fbf6fb
Compare
|
I have rebased the branch on top of the v7.0.0 release. |
|
Rebased against |
|
Hello @arnested, Thank you for your contribution and for adding support for RC and beta versions in the
Would you also be willing to extend this PR to accept Go-native versions with the Thank you again for your work on this! |
|
I'll have a look at it. It'll probably be in a week or so. I'm literally on the way to the airport for a vacation 🧳 |
|
I managed to squeeze in a bit of time and have pushed changes for the |
|
I had a first take at it. Think it worked, but although not complicated, it didn't find it very readable/easy to understand. Haven't gotten around to a second attempt, yet. |
|
Rebased onto origin/main. |
|
Hi @arnested, thank you for rebasing! It looks like the branch is still missing some recent changes from |
The regex in `parseGoVersionFile()` didn't consider rc and beta versions. The regex has been extended. In `findMatch()` the match is checked using `semver.satisfies()`. But `semver.satisfies()` doesn't no about Go's non-semver rc and beta version formats (1.16c1 instead of 1.16.0-rc.1). We cannot use `makeSemver()` on `versionSpec` and compare the result using `semver.satisfies()` because `versionSpec` could be, well, a spec. Instead we first check if there is a strict match between the candidate version and the versionSpec. Fixes actions#525.
Doh! It went a bit to fast this morning. I rebased against main on my fork 😄 I push a better rebase now 😄 |
Description:
The regex in
parseGoVersionFile()didn't consider rc and beta versions. The regex has been extended.In
findMatch()the match is checked usingsemver.satisfies(). Butsemver.satisfies()doesn't no about Go's non-semver rc and beta version formats (1.16c1 instead of 1.16.0-rc.1).We cannot use
makeSemver()onversionSpecand compare the result usingsemver.satisfies()becauseversionSpeccould be, well, a spec. Instead we first check if there is a strict match between the candidate version and the versionSpec.Related issue:
Fixes #525.
Check list: