Skip to content

Commit

Permalink
Consider truffleruby preview releases to be stable versions
Browse files Browse the repository at this point in the history
  • Loading branch information
eregon committed Apr 28, 2023
1 parent e939497 commit d2b39ad
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
2 changes: 1 addition & 1 deletion bundler.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export async function installBundler(bundlerVersionInput, rubygemsInputSet, lock

if (bundlerVersion === 'default') {
if (common.isBundler2dot2Default(engine, rubyVersion)) {
if (common.windows && engine === 'ruby' && (common.isStableVersion(rubyVersion) || rubyVersion === 'head')) {
if (common.windows && engine === 'ruby' && (common.isStableVersion(engine, rubyVersion) || rubyVersion === 'head')) {
// https://github.com/ruby/setup-ruby/issues/371
console.log(`Installing latest Bundler for ${engine}-${rubyVersion} on Windows because bin/bundle does not work in bash otherwise`)
bundlerVersion = 'latest'
Expand Down
8 changes: 6 additions & 2 deletions common.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,12 @@ export function isHeadVersion(rubyVersion) {
return ['head', 'debug', 'mingw', 'mswin', 'ucrt'].includes(rubyVersion)
}

export function isStableVersion(rubyVersion) {
return /^\d+(\.\d+)*$/.test(rubyVersion)
export function isStableVersion(engine, rubyVersion) {
if (engine.startsWith('truffleruby')) {
return /^\d+(\.\d+)*(-preview\d+)?$/.test(rubyVersion)
} else {
return /^\d+(\.\d+)*$/.test(rubyVersion)
}
}

export function hasBundlerDefaultGem(engine, rubyVersion) {
Expand Down
12 changes: 8 additions & 4 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ function validateRubyEngineAndVersion(platform, engineVersions, engine, parsedVe
if (!engineVersions.includes(parsedVersion)) {
const latestToFirstVersion = engineVersions.slice().reverse()
// Try to match stable versions first, so an empty version (engine-only) matches the latest stable version
let found = latestToFirstVersion.find(v => common.isStableVersion(v) && v.startsWith(parsedVersion))
let found = latestToFirstVersion.find(v => common.isStableVersion(engine, v) && v.startsWith(parsedVersion))
if (!found) {
// Exclude head versions, they must be exact matches
found = latestToFirstVersion.find(v => !common.isHeadVersion(v) && v.startsWith(parsedVersion))
Expand Down

0 comments on commit d2b39ad

Please sign in to comment.