dependabot-bundler 0.138.3 → 0.139.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/helpers/v1/run.rb +2 -0
- data/helpers/v1/spec/native_spec_helper.rb +3 -0
- data/helpers/v2/build +1 -0
- data/helpers/v2/lib/functions.rb +85 -12
- data/helpers/v2/lib/functions/dependency_source.rb +86 -0
- data/helpers/v2/lib/functions/force_updater.rb +167 -0
- data/helpers/v2/lib/functions/lockfile_updater.rb +224 -0
- data/helpers/v2/lib/functions/version_resolver.rb +140 -0
- data/helpers/v2/monkey_patches/definition_ruby_version_patch.rb +2 -2
- data/helpers/v2/run.rb +2 -2
- data/helpers/v2/spec/functions/dependency_source_spec.rb +185 -0
- data/helpers/v2/spec/functions/version_resolver_spec.rb +97 -0
- data/helpers/v2/spec/functions_spec.rb +15 -23
- data/helpers/v2/spec/native_spec_helper.rb +4 -0
- data/lib/dependabot/bundler/file_updater/requirement_replacer.rb +4 -2
- data/lib/dependabot/bundler/helpers.rb +23 -9
- data/lib/dependabot/bundler/update_checker.rb +12 -14
- data/lib/dependabot/bundler/update_checker/requirements_updater.rb +2 -2
- data/lib/dependabot/bundler/update_checker/shared_bundler_helpers.rb +3 -1
- metadata +12 -6
@@ -1,32 +1,24 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "native_spec_helper"
|
4
|
+
require "shared_contexts"
|
4
5
|
|
5
6
|
RSpec.describe Functions do
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
git_specs: [:dir, :gemfile_name, :credentials, :using_bundler2],
|
20
|
-
}.each do |function, kwargs|
|
21
|
-
describe "::#{function}" do
|
22
|
-
let(:args) do
|
23
|
-
kwargs.inject({}) do |args, keyword|
|
24
|
-
args.merge({ keyword => anything })
|
25
|
-
end
|
26
|
-
end
|
7
|
+
include_context "in a temporary bundler directory"
|
8
|
+
|
9
|
+
describe "#jfrog_source" do
|
10
|
+
let(:project_name) { "jfrog_source" }
|
11
|
+
|
12
|
+
it "returns the jfrog source" do
|
13
|
+
in_tmp_folder do
|
14
|
+
jfrog_source = Functions.jfrog_source(
|
15
|
+
dir: tmp_path,
|
16
|
+
gemfile_name: "Gemfile",
|
17
|
+
credentials: {},
|
18
|
+
using_bundler2: true
|
19
|
+
)
|
27
20
|
|
28
|
-
|
29
|
-
expect { Functions.send(function, **args) }.to raise_error(Functions::NotImplementedError)
|
21
|
+
expect(jfrog_source).to eq("test.jfrog.io")
|
30
22
|
end
|
31
23
|
end
|
32
24
|
end
|
@@ -26,7 +26,11 @@ end
|
|
26
26
|
LOCKFILE_ENDING = /(?<ending>\s*(?:RUBY VERSION|BUNDLED WITH).*)/m.freeze
|
27
27
|
|
28
28
|
def project_dependency_files(project)
|
29
|
+
# TODO: Retrieve files from bundler2 folder once it is fully up to date
|
29
30
|
project_path = File.expand_path(File.join("../../spec/fixtures/projects/bundler1", project))
|
31
|
+
|
32
|
+
raise "Fixture does not exist for project: '#{project}'" unless Dir.exist?(project_path)
|
33
|
+
|
30
34
|
Dir.chdir(project_path) do
|
31
35
|
# NOTE: Include dotfiles (e.g. .npmrc)
|
32
36
|
files = Dir.glob("**/*", File::FNM_DOTMATCH)
|
@@ -167,6 +167,8 @@ module Dependabot
|
|
167
167
|
req_string.include?(" ")
|
168
168
|
end
|
169
169
|
|
170
|
+
EQUALITY_OPERATOR = /(?<![<>!])=/.freeze
|
171
|
+
|
170
172
|
def use_equality_operator?(requirement_nodes)
|
171
173
|
return true if requirement_nodes.none?
|
172
174
|
|
@@ -178,7 +180,7 @@ module Dependabot
|
|
178
180
|
requirement_nodes.first.children.first.loc.expression.source
|
179
181
|
end
|
180
182
|
|
181
|
-
req_string.match?(
|
183
|
+
req_string.match?(EQUALITY_OPERATOR)
|
182
184
|
end
|
183
185
|
|
184
186
|
def new_requirement_string(quote_characters:,
|
@@ -203,7 +205,7 @@ module Dependabot
|
|
203
205
|
# Gem::Requirement serializes exact matches as a string starting
|
204
206
|
# with `=`. We may need to remove that equality operator if it
|
205
207
|
# wasn't used originally.
|
206
|
-
tmp_req = tmp_req.gsub(
|
208
|
+
tmp_req = tmp_req.gsub(EQUALITY_OPERATOR, "") unless use_equality_operator
|
207
209
|
|
208
210
|
tmp_req.strip
|
209
211
|
end
|
@@ -5,23 +5,37 @@ module Dependabot
|
|
5
5
|
module Helpers
|
6
6
|
V1 = "1"
|
7
7
|
V2 = "2"
|
8
|
+
# If we are updating a project with no Gemfile.lock, we default to the
|
9
|
+
# newest version we support
|
10
|
+
DEFAULT = V2
|
11
|
+
# If we are updating a project with a Gemfile.lock that does not specify
|
12
|
+
# the version it was bundled with, with failover to V1 on the assumption
|
13
|
+
# it was created with an old version that didn't add this information
|
14
|
+
FAILOVER = V1
|
8
15
|
|
9
|
-
|
10
|
-
def self.bundler_version(_lockfile, options:)
|
11
|
-
# For now, force V2 if bundler_2_available
|
12
|
-
return V2 if options[:bundler_2_available]
|
16
|
+
BUNDLER_MAJOR_VERSION_REGEX = /BUNDLED WITH\s+(?<version>\d+)\./m.freeze
|
13
17
|
|
14
|
-
|
15
|
-
|
18
|
+
# NOTE: options is a manditory argument to ensure we pass it from all calling classes
|
19
|
+
def self.bundler_version(lockfile, options:)
|
20
|
+
# TODO: Remove once bundler 2 is fully supported
|
21
|
+
return V1 unless options[:bundler_2_available]
|
22
|
+
return DEFAULT unless lockfile
|
16
23
|
|
17
|
-
|
24
|
+
if (matches = lockfile.content.match(BUNDLER_MAJOR_VERSION_REGEX))
|
25
|
+
matches[:version].to_i >= 2 ? V2 : V1
|
26
|
+
else
|
27
|
+
FAILOVER
|
28
|
+
end
|
18
29
|
end
|
19
30
|
|
20
31
|
def self.detected_bundler_version(lockfile)
|
21
32
|
return "unknown" unless lockfile
|
22
|
-
return V2 if lockfile.content.match?(/BUNDLED WITH\s+2/m)
|
23
33
|
|
24
|
-
|
34
|
+
if (matches = lockfile.content.match(BUNDLER_MAJOR_VERSION_REGEX))
|
35
|
+
matches[:version]
|
36
|
+
else
|
37
|
+
FAILOVER
|
38
|
+
end
|
25
39
|
end
|
26
40
|
end
|
27
41
|
end
|
@@ -359,20 +359,18 @@ module Dependabot
|
|
359
359
|
@version_resolver ||= {}
|
360
360
|
@version_resolver[remove_git_source] ||= {}
|
361
361
|
@version_resolver[remove_git_source][unlock_requirement] ||=
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
)
|
375
|
-
end
|
362
|
+
VersionResolver.new(
|
363
|
+
dependency: dependency,
|
364
|
+
unprepared_dependency_files: dependency_files,
|
365
|
+
repo_contents_path: repo_contents_path,
|
366
|
+
credentials: credentials,
|
367
|
+
ignored_versions: ignored_versions,
|
368
|
+
raise_on_ignored: raise_on_ignored,
|
369
|
+
remove_git_source: remove_git_source,
|
370
|
+
unlock_requirement: unlock_requirement,
|
371
|
+
latest_allowable_version: latest_version,
|
372
|
+
options: options
|
373
|
+
)
|
376
374
|
end
|
377
375
|
|
378
376
|
def latest_version_finder(remove_git_source:)
|
@@ -188,7 +188,7 @@ module Dependabot
|
|
188
188
|
req
|
189
189
|
end
|
190
190
|
when "<", "<=" then [update_greatest_version(req, latest_version)]
|
191
|
-
when "~>" then
|
191
|
+
when "~>" then convert_twiddle_to_range(req, latest_version)
|
192
192
|
when "!=" then []
|
193
193
|
when ">", ">=" then raise UnfixableRequirement
|
194
194
|
else raise "Unexpected operation for requirement: #{op}"
|
@@ -214,7 +214,7 @@ module Dependabot
|
|
214
214
|
end
|
215
215
|
end
|
216
216
|
|
217
|
-
def
|
217
|
+
def convert_twiddle_to_range(requirement, version_to_be_permitted)
|
218
218
|
version = requirement.requirements.first.last
|
219
219
|
version = version.release if version.prerelease?
|
220
220
|
|
@@ -187,7 +187,9 @@ module Dependabot
|
|
187
187
|
end
|
188
188
|
|
189
189
|
def jfrog_source
|
190
|
-
|
190
|
+
return @jfrog_source unless defined?(@jfrog_source)
|
191
|
+
|
192
|
+
@jfrog_source = in_a_native_bundler_context(error_handling: false) do |dir|
|
191
193
|
NativeHelpers.run_bundler_subprocess(
|
192
194
|
bundler_version: bundler_version,
|
193
195
|
function: "jfrog_source",
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dependabot-bundler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.139.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dependabot
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-03-
|
11
|
+
date: 2021-03-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dependabot-common
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 0.139.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.
|
26
|
+
version: 0.139.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: byebug
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -100,14 +100,14 @@ dependencies:
|
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: 1.
|
103
|
+
version: 1.12.0
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: 1.
|
110
|
+
version: 1.12.0
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: simplecov
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -211,13 +211,19 @@ files:
|
|
211
211
|
- helpers/v2/build
|
212
212
|
- helpers/v2/lib/functions.rb
|
213
213
|
- helpers/v2/lib/functions/conflicting_dependency_resolver.rb
|
214
|
+
- helpers/v2/lib/functions/dependency_source.rb
|
214
215
|
- helpers/v2/lib/functions/file_parser.rb
|
216
|
+
- helpers/v2/lib/functions/force_updater.rb
|
217
|
+
- helpers/v2/lib/functions/lockfile_updater.rb
|
218
|
+
- helpers/v2/lib/functions/version_resolver.rb
|
215
219
|
- helpers/v2/monkey_patches/definition_bundler_version_patch.rb
|
216
220
|
- helpers/v2/monkey_patches/definition_ruby_version_patch.rb
|
217
221
|
- helpers/v2/monkey_patches/git_source_patch.rb
|
218
222
|
- helpers/v2/run.rb
|
219
223
|
- helpers/v2/spec/functions/conflicting_dependency_resolver_spec.rb
|
224
|
+
- helpers/v2/spec/functions/dependency_source_spec.rb
|
220
225
|
- helpers/v2/spec/functions/file_parser_spec.rb
|
226
|
+
- helpers/v2/spec/functions/version_resolver_spec.rb
|
221
227
|
- helpers/v2/spec/functions_spec.rb
|
222
228
|
- helpers/v2/spec/native_spec_helper.rb
|
223
229
|
- helpers/v2/spec/shared_contexts.rb
|