@@ -6,7 +6,10 @@ const cache = require('@actions/cache')
6
6
const common = require ( './common' )
7
7
8
8
export 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
+ }
10
13
11
14
// The returned gemfile is guaranteed to exist, the lockfile might not exist
12
15
export function detectGemfiles ( ) {
@@ -33,7 +36,7 @@ function readBundledWithFromGemfileLock(lockFile) {
33
36
const nextLine = lines [ bundledWithLine + 1 ]
34
37
if ( nextLine ) {
35
38
const bundlerVersion = nextLine . trim ( )
36
- if ( BUNDLER_VERSION_REGEXP . test ( bundlerVersion ) ) {
39
+ if ( isValidBundlerVersion ( bundlerVersion ) ) {
37
40
console . log ( `Using Bundler ${ bundlerVersion } from ${ lockFile } BUNDLED WITH ${ bundlerVersion } ` )
38
41
return bundlerVersion
39
42
} else {
@@ -100,7 +103,7 @@ export async function installBundler(bundlerVersionInput, rubygemsInputSet, lock
100
103
bundlerVersion = '2'
101
104
}
102
105
103
- if ( BUNDLER_VERSION_REGEXP . test ( bundlerVersion ) ) {
106
+ if ( isValidBundlerVersion ( bundlerVersion ) ) {
104
107
// OK - input is a 1, 2, or 3 part version number
105
108
} else {
106
109
throw new Error ( `Cannot parse bundler input: ${ bundlerVersion } ` )
@@ -139,7 +142,7 @@ export async function installBundler(bundlerVersionInput, rubygemsInputSet, lock
139
142
const force = ( ( platform . startsWith ( 'windows-' ) && engine === 'ruby' && floatVersion >= 3.1 ) || ( engine === 'truffleruby' ) ) ? [ '--force' ] : [ ]
140
143
141
144
const versionParts = [ ...bundlerVersion . matchAll ( / \d + / g) ] . length
142
- const bundlerVersionConstraint = versionParts == = 3 ? bundlerVersion : `~> ${ bundlerVersion } .0`
145
+ const bundlerVersionConstraint = versionParts > = 3 ? bundlerVersion : `~> ${ bundlerVersion } .0`
143
146
144
147
await exec . exec ( gem , [ 'install' , 'bundler' , ...force , '-v' , bundlerVersionConstraint ] )
145
148
0 commit comments