Skip to content

Commit 2a0be7a

Browse files
committed
Try stable versions first, and then try non-head versions
* Fixes #115
1 parent bacba73 commit 2a0be7a

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
matrix:
1818
os: [ ubuntu-16.04, ubuntu-18.04, ubuntu-20.04, macos-10.15, macos-11.0, windows-2016, windows-2019 ]
1919
# Use various version syntax here for testing
20-
ruby: [ 2.1, 2.2, 2.3, 2.4, 2.5, 2.6.6, 2.7, ruby-3.0.0-preview1, ruby-head, debug, jruby-9.1, jruby, jruby-head, truffleruby, truffleruby-head ]
20+
ruby: [ 2.1, 2.2, 2.3, 2.4, 2.5, 2.6.6, 2.7, 3.0, ruby-head, debug, jruby-9.1, jruby, jruby-head, truffleruby, truffleruby-head ]
2121
include:
2222
- { os: windows-2016, ruby: mingw }
2323
- { os: windows-2019, ruby: mingw }

dist/index.js

Lines changed: 7 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,13 @@ function validateRubyEngineAndVersion(platform, engineVersions, engine, parsedVe
132132
let version = parsedVersion
133133
if (!engineVersions.includes(parsedVersion)) {
134134
const latestToFirstVersion = engineVersions.slice().reverse()
135-
const found = latestToFirstVersion.find(v => common.isStableVersion(v) && v.startsWith(parsedVersion))
135+
// Try to match stable versions first, so an empty version (engine-only) matches the latest stable version
136+
let found = latestToFirstVersion.find(v => common.isStableVersion(v) && v.startsWith(parsedVersion))
137+
if (!found) {
138+
// Exclude head versions, they must be exact matches
139+
found = latestToFirstVersion.find(v => !common.isHeadVersion(v) && v.startsWith(parsedVersion))
140+
}
141+
136142
if (found) {
137143
version = found
138144
} else {

0 commit comments

Comments
 (0)