Skip to content

Commit 4887fd8

Browse files
committed
Ignore Bundler dev version in Gemfile.lock
* Fixes #394
1 parent c4fe7bd commit 4887fd8

File tree

5 files changed

+47
-8
lines changed

5 files changed

+47
-8
lines changed

Diff for: .github/workflows/test.yml

+12
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,18 @@ jobs:
239239
bundler: 2.2.3
240240
- run: bundle --version | grep -F "Bundler version 2.2.3"
241241

242+
testBundlerDev:
243+
name: "Test BUNDLED WITH Bundler dev"
244+
runs-on: ubuntu-latest
245+
env:
246+
BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/bundler-dev.gemfile
247+
steps:
248+
- uses: actions/checkout@v3
249+
- uses: ./
250+
with:
251+
ruby-version: ruby-head
252+
bundler-cache: true
253+
242254
testDependencyOnBundler1:
243255
name: "Test gemfile depending on Bundler 1"
244256
runs-on: ubuntu-latest

Diff for: bundler.js

+9-4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const cache = require('@actions/cache')
66
const common = require('./common')
77

88
export const DEFAULT_CACHE_VERSION = '0'
9+
export const BUNDLER_VERSION_REGEXP = /^\d+(?:\.\d+){0,2}$/
910

1011
// The returned gemfile is guaranteed to exist, the lockfile might not exist
1112
export function detectGemfiles() {
@@ -30,10 +31,14 @@ function readBundledWithFromGemfileLock(lockFile) {
3031
const bundledWithLine = lines.findIndex(line => /^BUNDLED WITH$/.test(line.trim()))
3132
if (bundledWithLine !== -1) {
3233
const nextLine = lines[bundledWithLine+1]
33-
if (nextLine && /^\d+/.test(nextLine.trim())) {
34+
if (nextLine) {
3435
const bundlerVersion = nextLine.trim()
35-
console.log(`Using Bundler ${bundlerVersion} from ${lockFile} BUNDLED WITH ${bundlerVersion}`)
36-
return bundlerVersion
36+
if (BUNDLER_VERSION_REGEXP.test(bundlerVersion)) {
37+
console.log(`Using Bundler ${bundlerVersion} from ${lockFile} BUNDLED WITH ${bundlerVersion}`)
38+
return bundlerVersion
39+
} else {
40+
console.log(`Could not parse BUNDLED WITH version as a valid Bundler release, ignoring it: ${bundlerVersion}`)
41+
}
3742
}
3843
}
3944
}
@@ -95,7 +100,7 @@ export async function installBundler(bundlerVersionInput, rubygemsInputSet, lock
95100
bundlerVersion = '2'
96101
}
97102

98-
if (/^\d+(?:\.\d+){0,2}$/.test(bundlerVersion)) {
103+
if (BUNDLER_VERSION_REGEXP.test(bundlerVersion)) {
99104
// OK - input is a 1, 2, or 3 part version number
100105
} else {
101106
throw new Error(`Cannot parse bundler input: ${bundlerVersion}`)

Diff for: dist/index.js

+10-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: gemfiles/bundler-dev.gemfile

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
source 'https://rubygems.org'
2+
3+
gem "path"

Diff for: gemfiles/bundler-dev.gemfile.lock

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
GEM
2+
remote: https://rubygems.org/
3+
specs:
4+
path (2.0.1)
5+
6+
PLATFORMS
7+
x86_64-linux
8+
9+
DEPENDENCIES
10+
path
11+
12+
BUNDLED WITH
13+
2.4.0.dev

0 commit comments

Comments
 (0)