Skip to content

Commit

Permalink
Pin to bundler v2.1.0
Browse files Browse the repository at this point in the history
- Resolve lint
  • Loading branch information
brrygrdn committed Mar 30, 2021
1 parent f6b845d commit b75d941
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion bundler/helpers/v2/run.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

require "functions"

MIN_BUNDLER_VERSION = "2.0.0"
MIN_BUNDLER_VERSION = "2.1.0"

def validate_bundler_version!
return true if correct_bundler_version?
Expand Down
7 changes: 4 additions & 3 deletions bundler/lib/dependabot/bundler/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ module Helpers
# it was created with an old version that didn't add this information
FAILOVER = V1

BUNDLER_MAJOR_VERSION_REGEX = /BUNDLED WITH\s+(?<version>\d+)\./m
BUNDLER_MAJOR_VERSION_REGEX = /BUNDLED WITH\s+(?<version>\d+)\./m.freeze

# NOTE: options is a manditory argument to ensure we pass it from all calling classes
def self.bundler_version(lockfile, options:)
# TODO: Remove once bundler 2 is fully supported
return V1 unless options[:bundler_2_available]
return DEFAULT unless lockfile

if matches = lockfile.content.match(BUNDLER_MAJOR_VERSION_REGEX)
if (matches = lockfile.content.match(BUNDLER_MAJOR_VERSION_REGEX))
matches[:version].to_i >= 2 ? V2 : V1
else
FAILOVER
Expand All @@ -30,7 +30,8 @@ def self.bundler_version(lockfile, options:)

def self.detected_bundler_version(lockfile)
return "unknown" unless lockfile
if matches = lockfile.content.match(BUNDLER_MAJOR_VERSION_REGEX)

if (matches = lockfile.content.match(BUNDLER_MAJOR_VERSION_REGEX))
matches[:version]
else
FAILOVER
Expand Down
18 changes: 9 additions & 9 deletions bundler/spec/dependabot/bundler/helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
LOCKFILE
end

let(:lockfile_bundled_with_1) do
let(:lockfile_bundled_with_v1) do
Dependabot::DependencyFile.new(name: "Gemfile.lock", content: <<~LOCKFILE)
Mock Gemfile.lock Content Goes Here
Expand All @@ -22,7 +22,7 @@
LOCKFILE
end

let(:lockfile_bundled_with_2) do
let(:lockfile_bundled_with_v2) do
Dependabot::DependencyFile.new(name: "Gemfile.lock", content: <<~LOCKFILE)
Mock Gemfile.lock Content Goes Here
Expand All @@ -46,7 +46,7 @@ def described_method(lockfile)
end

context "when bundler 2 is not available" do
let(:options) { Hash.new }
let(:options) { {} }

it "is 1 if there is no lockfile" do
expect(described_method(no_lockfile)).to eql("1")
Expand All @@ -57,11 +57,11 @@ def described_method(lockfile)
end

it "is 1 if it was bundled with a v1.x version" do
expect(described_method(lockfile_bundled_with_1)).to eql("1")
expect(described_method(lockfile_bundled_with_v1)).to eql("1")
end

it "is 1 if it was bundled with a v2.x version" do
expect(described_method(lockfile_bundled_with_2)).to eql("1")
expect(described_method(lockfile_bundled_with_v2)).to eql("1")
end

it "is 1 if it was bundled with a future version" do
Expand All @@ -83,11 +83,11 @@ def described_method(lockfile)
end

it "is 1 if it was bundled with a v1.x version" do
expect(described_method(lockfile_bundled_with_1)).to eql("1")
expect(described_method(lockfile_bundled_with_v1)).to eql("1")
end

it "is 2 if it was bundled with a v2.x version" do
expect(described_method(lockfile_bundled_with_2)).to eql("2")
expect(described_method(lockfile_bundled_with_v2)).to eql("2")
end

it "is 2 if it was bundled with a future version" do
Expand All @@ -110,11 +110,11 @@ def described_method(lockfile)
end

it "is 1 if it was bundled with a v1.x version" do
expect(described_method(lockfile_bundled_with_1)).to eql("1")
expect(described_method(lockfile_bundled_with_v1)).to eql("1")
end

it "is 2 if it was bundled with a v2.x version" do
expect(described_method(lockfile_bundled_with_2)).to eql("2")
expect(described_method(lockfile_bundled_with_v2)).to eql("2")
end

it "is 1 if it was bundled with a future version" do
Expand Down

0 comments on commit b75d941

Please sign in to comment.