@@ -6,7 +6,10 @@ const cache = require('@actions/cache')
66const common = require ( './common' )
77
88export const DEFAULT_CACHE_VERSION = '0'
9- export const BUNDLER_VERSION_REGEXP = / ^ \d + (?: \. \d + ) { 0 , 2 } $ /
9+
10+ function isValidBundlerVersion ( bundlerVersion ) {
11+ return / ^ \d + (?: \. \d + ) { 0 , 2 } / . test ( bundlerVersion ) && ! bundlerVersion . endsWith ( '.dev' )
12+ }
1013
1114// The returned gemfile is guaranteed to exist, the lockfile might not exist
1215export function detectGemfiles ( ) {
@@ -33,7 +36,7 @@ function readBundledWithFromGemfileLock(lockFile) {
3336 const nextLine = lines [ bundledWithLine + 1 ]
3437 if ( nextLine ) {
3538 const bundlerVersion = nextLine . trim ( )
36- if ( BUNDLER_VERSION_REGEXP . test ( bundlerVersion ) ) {
39+ if ( isValidBundlerVersion ( bundlerVersion ) ) {
3740 console . log ( `Using Bundler ${ bundlerVersion } from ${ lockFile } BUNDLED WITH ${ bundlerVersion } ` )
3841 return bundlerVersion
3942 } else {
@@ -100,7 +103,7 @@ export async function installBundler(bundlerVersionInput, rubygemsInputSet, lock
100103 bundlerVersion = '2'
101104 }
102105
103- if ( BUNDLER_VERSION_REGEXP . test ( bundlerVersion ) ) {
106+ if ( isValidBundlerVersion ( bundlerVersion ) ) {
104107 // OK - input is a 1, 2, or 3 part version number
105108 } else {
106109 throw new Error ( `Cannot parse bundler input: ${ bundlerVersion } ` )
@@ -139,7 +142,7 @@ export async function installBundler(bundlerVersionInput, rubygemsInputSet, lock
139142 const force = ( ( platform . startsWith ( 'windows-' ) && engine === 'ruby' && floatVersion >= 3.1 ) || ( engine === 'truffleruby' ) ) ? [ '--force' ] : [ ]
140143
141144 const versionParts = [ ...bundlerVersion . matchAll ( / \d + / g) ] . length
142- const bundlerVersionConstraint = versionParts == = 3 ? bundlerVersion : `~> ${ bundlerVersion } .0`
145+ const bundlerVersionConstraint = versionParts > = 3 ? bundlerVersion : `~> ${ bundlerVersion } .0`
143146
144147 await exec . exec ( gem , [ 'install' , 'bundler' , ...force , '-v' , bundlerVersionConstraint ] )
145148
0 commit comments