dependabot-bundler 0.124.7 → 0.125.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f4d15ee063593d04b7f298c043ca8a710cdb8573b8a7fb7daf88c959eda7c3aa
4
- data.tar.gz: fc3ae6855cb63559940cc54cdb1a71242cb56d13b0209edb907c4d90bf037bbb
3
+ metadata.gz: 83152b291442fad26ff65f29c1357211aa955fc95b204155f86b963e99e489e1
4
+ data.tar.gz: 00dddfab3bd6c04bc970a4bceb44cdaa7ae9fb16a9b333568800acb05da093cc
5
5
  SHA512:
6
- metadata.gz: 547c622f6f08fd277eb951134b94b64c0b7e550330eb466382baa0bbfd20148fedd1d303faab81a8ed3b75d67c1ddaa54253bc336b3111cad089a83af032ba18
7
- data.tar.gz: 5c45aacff60e26b8ae224ab03bd8c0eceaa2622ba159279d106f260e99a2c4fb3a7b1cb621bf9cbdb168134968b90a3a11442ea12cc84024fc4994bb32332f80
6
+ metadata.gz: b8f217c42f75084d95dfe83426476cb28f0b415e92ff3f45a72b453dedf523bed7c2b4bd2e4ca2aab81800c4669da9c53c1bfbed5aee07b72ed25916cac57c27
7
+ data.tar.gz: c86d612ffd4eed616dab8538f9f984155e0c3ce9e826d6a6fe6e2d06f89bd8108de41d2e7f898e4a83bbaa71d8e5b13fc04459cd43b25e0cf49bdda362c23257
@@ -14,9 +14,7 @@ module Dependabot
14
14
  require "dependabot/bundler/file_fetcher/require_relative_finder"
15
15
 
16
16
  def self.required_files_in?(filenames)
17
- if filenames.any? { |name| name.match?(%r{^[^/]*\.gemspec$}) }
18
- return true
19
- end
17
+ return true if filenames.any? { |name| name.match?(%r{^[^/]*\.gemspec$}) }
20
18
 
21
19
  filenames.include?("Gemfile") || filenames.include?("gems.rb")
22
20
  end
@@ -133,9 +131,7 @@ module Dependabot
133
131
  unfetchable_gems << path.basename.to_s
134
132
  end
135
133
 
136
- if unfetchable_gems.any?
137
- raise Dependabot::PathDependenciesNotReachable, unfetchable_gems
138
- end
134
+ raise Dependabot::PathDependenciesNotReachable, unfetchable_gems if unfetchable_gems.any?
139
135
 
140
136
  gemspec_files.tap { |ar| ar.each { |f| f.support_file = true } }
141
137
  end
@@ -204,9 +204,7 @@ module Dependabot
204
204
 
205
205
  # If the source is Git we're better off knowing the SHA-1 than the
206
206
  # version.
207
- if spec.source.instance_of?(::Bundler::Source::Git)
208
- return spec.source.revision
209
- end
207
+ return spec.source.revision if spec.source.instance_of?(::Bundler::Source::Git)
210
208
 
211
209
  spec.version
212
210
  end
@@ -94,9 +94,7 @@ module Dependabot
94
94
  def check_required_files
95
95
  file_names = dependency_files.map(&:name)
96
96
 
97
- if lockfile && !gemfile
98
- raise "A Gemfile must be provided if a lockfile is!"
99
- end
97
+ raise "A Gemfile must be provided if a lockfile is!" if lockfile && !gemfile
100
98
 
101
99
  return if file_names.any? { |name| name.match?(%r{^[^/]*\.gemspec$}) }
102
100
  return if gemfile
@@ -25,13 +25,9 @@ module Dependabot
25
25
  content
26
26
  )
27
27
 
28
- if remove_git_source?(dependency)
29
- content = remove_gemfile_git_source(dependency, content)
30
- end
28
+ content = remove_gemfile_git_source(dependency, content) if remove_git_source?(dependency)
31
29
 
32
- if update_git_pin?(dependency)
33
- content = update_gemfile_git_pin(dependency, gemfile, content)
34
- end
30
+ content = update_gemfile_git_pin(dependency, gemfile, content) if update_git_pin?(dependency)
35
31
  end
36
32
 
37
33
  content
@@ -100,9 +100,7 @@ module Dependabot
100
100
  def replace_version_assignments(node)
101
101
  return unless node.is_a?(Parser::AST::Node)
102
102
 
103
- if node_assigns_to_version_constant?(node)
104
- return replace_constant(node)
105
- end
103
+ return replace_constant(node) if node_assigns_to_version_constant?(node)
106
104
 
107
105
  node.children.each { |child| replace_version_assignments(child) }
108
106
  end
@@ -110,9 +108,7 @@ module Dependabot
110
108
  def replace_version_constant_references(node)
111
109
  return unless node.is_a?(Parser::AST::Node)
112
110
 
113
- if node_is_version_constant?(node)
114
- return replace(node.loc.expression, %("#{replacement_version}"))
115
- end
111
+ return replace(node.loc.expression, %("#{replacement_version}")) if node_is_version_constant?(node)
116
112
 
117
113
  node.children.each do |child|
118
114
  replace_version_constant_references(child)
@@ -122,9 +118,7 @@ module Dependabot
122
118
  def replace_file_assignments(node)
123
119
  return unless node.is_a?(Parser::AST::Node)
124
120
 
125
- if node_assigns_files_to_var?(node)
126
- return replace_file_assignment(node)
127
- end
121
+ return replace_file_assignment(node) if node_assigns_files_to_var?(node)
128
122
 
129
123
  node.children.each { |child| replace_file_assignments(child) }
130
124
  end
@@ -132,9 +126,7 @@ module Dependabot
132
126
  def replace_require_paths_assignments(node)
133
127
  return unless node.is_a?(Parser::AST::Node)
134
128
 
135
- if node_assigns_require_paths?(node)
136
- return replace_require_paths_assignment(node)
137
- end
129
+ return replace_require_paths_assignment(node) if node_assigns_require_paths?(node)
138
130
 
139
131
  node.children.each do |child|
140
132
  replace_require_paths_assignments(child)
@@ -44,9 +44,7 @@ module Dependabot
44
44
  begin
45
45
  updated_content = build_updated_lockfile
46
46
 
47
- if lockfile.content == updated_content
48
- raise "Expected content to change!"
49
- end
47
+ raise "Expected content to change!" if lockfile.content == updated_content
50
48
 
51
49
  updated_content
52
50
  end
@@ -64,9 +64,7 @@ module Dependabot
64
64
  end
65
65
 
66
66
  def length_change
67
- unless previous_requirement.start_with?("=")
68
- return updated_requirement.length - previous_requirement.length
69
- end
67
+ return updated_requirement.length - previous_requirement.length unless previous_requirement.start_with?("=")
70
68
 
71
69
  updated_requirement.length -
72
70
  previous_requirement.gsub(/^=/, "").strip.length
@@ -205,9 +203,7 @@ module Dependabot
205
203
  # Gem::Requirement serializes exact matches as a string starting
206
204
  # with `=`. We may need to remove that equality operator if it
207
205
  # wasn't used originally.
208
- unless use_equality_operator
209
- tmp_req = tmp_req.gsub(/(?<![<>])=/, "")
210
- end
206
+ tmp_req = tmp_req.gsub(/(?<![<>])=/, "") unless use_equality_operator
211
207
 
212
208
  tmp_req.strip
213
209
  end
@@ -120,9 +120,7 @@ module Dependabot
120
120
  # Note: This response MUST NOT be unmarshalled
121
121
  # (as calling Marshal.load is unsafe)
122
122
  def rubygems_marshalled_gemspec_response
123
- if defined?(@rubygems_marshalled_gemspec_response)
124
- return @rubygems_marshalled_gemspec_response
125
- end
123
+ return @rubygems_marshalled_gemspec_response if defined?(@rubygems_marshalled_gemspec_response)
126
124
 
127
125
  gemspec_uri =
128
126
  "#{registry_url}quick/Marshal.4.8/"\
@@ -135,9 +133,7 @@ module Dependabot
135
133
  **SharedHelpers.excon_defaults(headers: registry_auth_headers)
136
134
  )
137
135
 
138
- if response.status >= 400
139
- return @rubygems_marshalled_gemspec_response = nil
140
- end
136
+ return @rubygems_marshalled_gemspec_response = nil if response.status >= 400
141
137
 
142
138
  @rubygems_marshalled_gemspec_response =
143
139
  Zlib::Inflate.inflate(response.body)
@@ -13,6 +13,7 @@ module Dependabot
13
13
  require_relative "update_checker/requirements_updater"
14
14
  require_relative "update_checker/version_resolver"
15
15
  require_relative "update_checker/latest_version_finder"
16
+ require_relative "update_checker/conflicting_dependency_resolver"
16
17
 
17
18
  def latest_version
18
19
  return latest_version_for_git_dependency if git_dependency?
@@ -99,14 +100,23 @@ module Dependabot
99
100
 
100
101
  def requirements_update_strategy
101
102
  # If passed in as an option (in the base class) honour that option
102
- if @requirements_update_strategy
103
- return @requirements_update_strategy.to_sym
104
- end
103
+ return @requirements_update_strategy.to_sym if @requirements_update_strategy
105
104
 
106
105
  # Otherwise, widen ranges for libraries and bump versions for apps
107
106
  dependency.version.nil? ? :bump_versions_if_necessary : :bump_versions
108
107
  end
109
108
 
109
+ def conflicting_dependencies
110
+ ConflictingDependencyResolver.new(
111
+ dependency_files: dependency_files,
112
+ repo_contents_path: repo_contents_path,
113
+ credentials: credentials
114
+ ).conflicting_dependencies(
115
+ dependency: dependency,
116
+ target_version: lowest_security_fix_version
117
+ )
118
+ end
119
+
110
120
  private
111
121
 
112
122
  def latest_version_resolvable_with_full_unlock?
@@ -130,9 +140,7 @@ module Dependabot
130
140
  end
131
141
 
132
142
  def preferred_resolvable_version_details
133
- if vulnerable?
134
- return { version: lowest_resolvable_security_fix_version }
135
- end
143
+ return { version: lowest_resolvable_security_fix_version } if vulnerable?
136
144
 
137
145
  latest_resolvable_version_details
138
146
  end
@@ -208,9 +216,7 @@ module Dependabot
208
216
 
209
217
  # Otherwise, if the gem isn't pinned, the latest version is just the
210
218
  # latest commit for the specified branch.
211
- unless git_commit_checker.pinned?
212
- return git_commit_checker.head_commit_for_current_branch
213
- end
219
+ return git_commit_checker.head_commit_for_current_branch unless git_commit_checker.pinned?
214
220
 
215
221
  # If the dependency is pinned to a tag that looks like a version then
216
222
  # we want to update that tag. The latest version will then be the SHA
@@ -234,9 +240,7 @@ module Dependabot
234
240
 
235
241
  # Otherwise, if the gem isn't pinned, the latest version is just the
236
242
  # latest commit for the specified branch.
237
- unless git_commit_checker.pinned?
238
- return latest_resolvable_commit_with_unchanged_git_source
239
- end
243
+ return latest_resolvable_commit_with_unchanged_git_source unless git_commit_checker.pinned?
240
244
 
241
245
  # If the dependency is pinned to a tag that looks like a version then
242
246
  # we want to update that tag. The latest version will then be the SHA
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "dependabot/bundler/update_checker"
4
+ require "dependabot/bundler/native_helpers"
5
+ require "dependabot/shared_helpers"
6
+
7
+ module Dependabot
8
+ module Bundler
9
+ class UpdateChecker < UpdateCheckers::Base
10
+ class ConflictingDependencyResolver
11
+ require_relative "shared_bundler_helpers"
12
+ include SharedBundlerHelpers
13
+
14
+ def initialize(dependency_files:, repo_contents_path:, credentials:)
15
+ @dependency_files = dependency_files
16
+ @repo_contents_path = repo_contents_path
17
+ @credentials = credentials
18
+ end
19
+
20
+ # Finds any dependencies in the lockfile that have a subdependency on
21
+ # the given dependency that does not satisfly the target_version.
22
+ #
23
+ # @param dependency [Dependabot::Dependency] the dependency to check
24
+ # @param target_version [String] the version to check
25
+ # @return [Array<Hash{String => String}]
26
+ # * name [String] the blocking dependencies name
27
+ # * version [String] the version of the blocking dependency
28
+ # * requirement [String] the requirement on the target_dependency
29
+ def conflicting_dependencies(dependency:, target_version:)
30
+ in_a_native_bundler_context(error_handling: false) do |tmp_dir|
31
+ SharedHelpers.run_helper_subprocess(
32
+ command: NativeHelpers.helper_path,
33
+ function: "conflicting_dependencies",
34
+ args: {
35
+ dir: tmp_dir,
36
+ dependency_name: dependency.name,
37
+ target_version: target_version,
38
+ credentials: relevant_credentials,
39
+ lockfile_name: lockfile.name,
40
+ using_bundler_2: using_bundler_2?
41
+ }
42
+ )
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
@@ -207,9 +207,7 @@ module Dependabot
207
207
  lower_bound_req = updated_version_req_lower_bound(filename)
208
208
 
209
209
  return lower_bound_req if latest_allowable_version.nil?
210
- unless Gem::Version.correct?(latest_allowable_version)
211
- return lower_bound_req
212
- end
210
+ return lower_bound_req unless Gem::Version.correct?(latest_allowable_version)
213
211
 
214
212
  lower_bound_req + ", <= #{latest_allowable_version}"
215
213
  end
@@ -39,9 +39,7 @@ module Dependabot
39
39
  :credentials, :ignored_versions, :security_advisories
40
40
 
41
41
  def fetch_latest_version_details
42
- if dependency_source.git?
43
- return dependency_source.latest_git_version_details
44
- end
42
+ return dependency_source.latest_git_version_details if dependency_source.git?
45
43
 
46
44
  relevant_versions = dependency_source.versions
47
45
  relevant_versions = filter_prerelease_versions(relevant_versions)
@@ -71,9 +69,7 @@ module Dependabot
71
69
  def filter_ignored_versions(versions_array)
72
70
  filtered = versions_array.
73
71
  reject { |v| ignore_reqs.any? { |r| r.satisfied_by?(v) } }
74
- if @raise_on_ignored && filtered.empty? && versions_array.any?
75
- raise AllVersionsIgnored
76
- end
72
+ raise AllVersionsIgnored if @raise_on_ignored && filtered.empty? && versions_array.any?
77
73
 
78
74
  filtered
79
75
  end
@@ -228,9 +228,7 @@ module Dependabot
228
228
  lb_segments = version.segments
229
229
  lb_segments.pop while lb_segments.any? && lb_segments.last.zero?
230
230
 
231
- if lb_segments.none?
232
- return [Gem::Requirement.new("< #{ub_segments.join('.')}")]
233
- end
231
+ return [Gem::Requirement.new("< #{ub_segments.join('.')}")] if lb_segments.none?
234
232
 
235
233
  # Ensure versions have the same length as each other (cosmetic)
236
234
  length = [lb_segments.count, ub_segments.count].max
@@ -253,9 +251,7 @@ module Dependabot
253
251
  # Updates the version in a "<" or "<=" constraint to allow the given
254
252
  # version
255
253
  def update_greatest_version(requirement, version_to_be_permitted)
256
- if version_to_be_permitted.is_a?(String)
257
- version_to_be_permitted = Gem::Version.new(version_to_be_permitted)
258
- end
254
+ version_to_be_permitted = Gem::Version.new(version_to_be_permitted) if version_to_be_permitted.is_a?(String)
259
255
  op, version = requirement.requirements.first
260
256
  version = version.release if version.prerelease?
261
257
 
@@ -55,9 +55,7 @@ module Dependabot
55
55
  rescue SharedHelpers::HelperSubprocessFailed => e
56
56
  retry_count ||= 0
57
57
  retry_count += 1
58
- if retryable_error?(e) && retry_count <= 2
59
- sleep(rand(1.0..5.0)) && retry
60
- end
58
+ sleep(rand(1.0..5.0)) && retry if retryable_error?(e) && retry_count <= 2
61
59
 
62
60
  error_handling ? handle_bundler_errors(e) : raise
63
61
  end
@@ -70,9 +68,7 @@ module Dependabot
70
68
  return true if error.error_class == "JSON::ParserError"
71
69
  return true if RETRYABLE_ERRORS.include?(error.error_class)
72
70
 
73
- unless RETRYABLE_PRIVATE_REGISTRY_ERRORS.include?(error.error_class)
74
- return false
75
- end
71
+ return false unless RETRYABLE_PRIVATE_REGISTRY_ERRORS.include?(error.error_class)
76
72
 
77
73
  private_registry_credentials.any?
78
74
  end
@@ -119,9 +119,7 @@ module Dependabot
119
119
  # rubocop:enable Metrics/PerceivedComplexity
120
120
 
121
121
  def circular_dependency_at_new_version?(error)
122
- unless error.error_class.include?("CyclicDependencyError")
123
- return false
124
- end
122
+ return false unless error.error_class.include?("CyclicDependencyError")
125
123
 
126
124
  error.message.include?("'#{dependency.name}'")
127
125
  end
@@ -171,9 +169,7 @@ module Dependabot
171
169
 
172
170
  def ruby_version_incompatible?(details)
173
171
  # It's only the old index we have a problem with
174
- unless details[:fetcher] == "Bundler::Fetcher::Dependency"
175
- return false
176
- end
172
+ return false unless details[:fetcher] == "Bundler::Fetcher::Dependency"
177
173
 
178
174
  # If no Ruby version is specified, we don't have a problem
179
175
  return false unless details[:ruby_version]
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.124.7
4
+ version: 0.125.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dependabot
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-11-03 00:00:00.000000000 Z
11
+ date: 2020-11-16 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.124.7
19
+ version: 0.125.3
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.124.7
26
+ version: 0.125.3
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: byebug
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -128,14 +128,14 @@ dependencies:
128
128
  requirements:
129
129
  - - "~>"
130
130
  - !ruby/object:Gem::Version
131
- version: 0.7.2
131
+ version: 0.8.0
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
- version: 0.7.2
138
+ version: 0.8.0
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: vcr
141
141
  requirement: !ruby/object:Gem::Requirement
@@ -194,6 +194,7 @@ files:
194
194
  - lib/dependabot/bundler/native_helpers.rb
195
195
  - lib/dependabot/bundler/requirement.rb
196
196
  - lib/dependabot/bundler/update_checker.rb
197
+ - lib/dependabot/bundler/update_checker/conflicting_dependency_resolver.rb
197
198
  - lib/dependabot/bundler/update_checker/file_preparer.rb
198
199
  - lib/dependabot/bundler/update_checker/force_updater.rb
199
200
  - lib/dependabot/bundler/update_checker/latest_version_finder.rb