dependabot-bundler 0.134.0 → 0.134.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (26) hide show
  1. checksums.yaml +4 -4
  2. data/helpers/v1/.gitignore +8 -0
  3. data/helpers/v1/Gemfile +16 -0
  4. data/helpers/{build → v1/build} +9 -0
  5. data/helpers/{lib → v1/lib}/functions.rb +0 -0
  6. data/helpers/{lib → v1/lib}/functions/conflicting_dependency_resolver.rb +0 -0
  7. data/helpers/{lib → v1/lib}/functions/dependency_source.rb +0 -0
  8. data/helpers/{lib → v1/lib}/functions/file_parser.rb +0 -0
  9. data/helpers/{lib → v1/lib}/functions/force_updater.rb +0 -0
  10. data/helpers/{lib → v1/lib}/functions/lockfile_updater.rb +0 -0
  11. data/helpers/{lib → v1/lib}/functions/version_resolver.rb +0 -0
  12. data/helpers/{monkey_patches → v1/monkey_patches}/definition_bundler_version_patch.rb +0 -0
  13. data/helpers/{monkey_patches → v1/monkey_patches}/definition_ruby_version_patch.rb +0 -0
  14. data/helpers/{monkey_patches → v1/monkey_patches}/git_source_patch.rb +0 -0
  15. data/helpers/{run.rb → v1/run.rb} +0 -0
  16. data/lib/dependabot/bundler/file_parser.rb +9 -4
  17. data/lib/dependabot/bundler/file_updater.rb +7 -2
  18. data/lib/dependabot/bundler/file_updater/lockfile_updater.rb +7 -2
  19. data/lib/dependabot/bundler/helpers.rb +16 -0
  20. data/lib/dependabot/bundler/native_helpers.rb +31 -2
  21. data/lib/dependabot/bundler/update_checker/conflicting_dependency_resolver.rb +9 -2
  22. data/lib/dependabot/bundler/update_checker/force_updater.rb +7 -2
  23. data/lib/dependabot/bundler/update_checker/latest_version_finder/dependency_source.rb +18 -6
  24. data/lib/dependabot/bundler/update_checker/shared_bundler_helpers.rb +9 -4
  25. data/lib/dependabot/bundler/update_checker/version_resolver.rb +7 -2
  26. metadata +19 -16
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8f3854e6b2cf2c17c4e92f8252df00d517d0c26c486e9a2e3d3e3a4c2258a82d
4
- data.tar.gz: fbd26678537fd4a34aa9224fa9b91d26c26f7895fd01fb5d49f826a4291eb94b
3
+ metadata.gz: bd78c19685f05d6c7e43ce4c90534222628ae2643f85c0e9e782564ad9c103f5
4
+ data.tar.gz: d6d3b64c7fe549a55393b3f8fc7abc8f4ab47beeedff11693b55f3063dd574c1
5
5
  SHA512:
6
- metadata.gz: db4a62cebe08642fd925b13eee0b58d76fd554d7996660951e181d3673a57782aafa215f3663f4029a0b1c430bc824a4f92715e31f263dcb455d4fe51f9a6fdd
7
- data.tar.gz: 561c2f3d3f38f2f81007ae70c03c4c1a0febf30902b8095d7162ad9ce4e4636a3296f1550ba22a856cddf757b764e77082c315e31da12bc4121c378cb6282573
6
+ metadata.gz: fbd76caef56c07824885903d9d17f435143889e7e7e8923a11290ba1e532e80a7808de62f775eebf513e71620062bc70a9609b8e28d48310abcbde05dc79fcaa
7
+ data.tar.gz: c73e87e7383c1ea48dbd58e97dde9011c83eefb3f3730c4f98756c64793ae374e102577ca911418edc8d8553a629d72356663062c39d44678513c3f47e11a6b2
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.env
3
+ /tmp
4
+ /dependabot-*.gem
5
+ Gemfile.lock
6
+ spec/fixtures/projects/*/.bundle/
7
+ !spec/fixtures/projects/**/Gemfile.lock
8
+ !spec/fixtures/projects/**/vendor
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ # TODO: Look into removing this. "find" used to get required from common's
4
+ # gemspec so we've added it here for backwards compatability during bundler 2
5
+ # rollout.
6
+ #
7
+ # NOTE: If we don't require it and a customers `.gemspec` uses Find without
8
+ # requiring it, we'll start raising a DependencyFileNotEvaluatable error which
9
+ # is probably the right thing to do
10
+ require "find"
11
+
12
+ source "https://rubygems.org"
13
+
14
+ # NOTE: This is intentionally left blank as it's currently only used to force
15
+ # bundler to use v1 when executing native helpers by pointing the BUNDLE_GEMFILE
16
+ # env to this Gemfile in Dependabot::Bundler::NativeHelpers
@@ -8,11 +8,20 @@ if [ -z "$install_dir" ]; then
8
8
  exit 1
9
9
  fi
10
10
 
11
+ if [ ! -d "$install_dir" ]; then
12
+ mkdir -p "$install_dir"
13
+ fi
14
+
11
15
  helpers_dir="$(dirname "${BASH_SOURCE[0]}")"
12
16
  cp -r \
13
17
  "$helpers_dir/lib" \
14
18
  "$helpers_dir/monkey_patches" \
15
19
  "$helpers_dir/run.rb" \
20
+ "$helpers_dir/Gemfile" \
16
21
  "$install_dir"
17
22
 
18
23
  cd "$install_dir"
24
+
25
+ # NOTE: Sets `BUNDLED WITH` to match the installed v1 version in Gemfile.lock
26
+ # forcing specs and native helpers to run with the same version
27
+ BUNDLER_VERSION=1 bundle install
File without changes
File without changes
File without changes
File without changes
@@ -5,6 +5,7 @@ require "dependabot/file_parsers"
5
5
  require "dependabot/file_parsers/base"
6
6
  require "dependabot/bundler/file_updater/lockfile_updater"
7
7
  require "dependabot/bundler/native_helpers"
8
+ require "dependabot/bundler/helpers"
8
9
  require "dependabot/bundler/version"
9
10
  require "dependabot/shared_helpers"
10
11
  require "dependabot/errors"
@@ -129,8 +130,8 @@ module Dependabot
129
130
  repo_contents_path) do
130
131
  write_temporary_dependency_files
131
132
 
132
- SharedHelpers.run_helper_subprocess(
133
- command: NativeHelpers.helper_path,
133
+ NativeHelpers.run_bundler_subprocess(
134
+ bundler_version: bundler_version,
134
135
  function: "parsed_gemfile",
135
136
  args: {
136
137
  gemfile_name: gemfile.name,
@@ -159,8 +160,8 @@ module Dependabot
159
160
  repo_contents_path) do
160
161
  write_temporary_dependency_files
161
162
 
162
- SharedHelpers.run_helper_subprocess(
163
- command: NativeHelpers.helper_path,
163
+ NativeHelpers.run_bundler_subprocess(
164
+ bundler_version: bundler_version,
164
165
  function: "parsed_gemspec",
165
166
  args: {
166
167
  gemspec_name: file.name,
@@ -298,6 +299,10 @@ module Dependabot
298
299
  select { |f| f.name.end_with?(".rb") }.
299
300
  reject { |f| f.name == "gems.rb" }
300
301
  end
302
+
303
+ def bundler_version
304
+ @bundler_version ||= Helpers.bundler_version(lockfile)
305
+ end
301
306
  end
302
307
  end
303
308
  end
@@ -3,6 +3,7 @@
3
3
  require "dependabot/file_updaters"
4
4
  require "dependabot/file_updaters/base"
5
5
  require "dependabot/bundler/native_helpers"
6
+ require "dependabot/bundler/helpers"
6
7
  require "dependabot/file_updaters/vendor_updater"
7
8
 
8
9
  module Dependabot
@@ -75,8 +76,8 @@ module Dependabot
75
76
  return @vendor_cache_dir if defined?(@vendor_cache_dir)
76
77
 
77
78
  @vendor_cache_dir =
78
- SharedHelpers.run_helper_subprocess(
79
- command: NativeHelpers.helper_path,
79
+ NativeHelpers.run_bundler_subprocess(
80
+ bundler_version: bundler_version,
80
81
  function: "vendor_cache_dir",
81
82
  args: {
82
83
  dir: repo_contents_path
@@ -159,6 +160,10 @@ module Dependabot
159
160
  select { |file| file.name.end_with?(".gemspec") }.
160
161
  reject(&:support_file?)
161
162
  end
163
+
164
+ def bundler_version
165
+ @bundler_version ||= Helpers.bundler_version(lockfile)
166
+ end
162
167
  end
163
168
  end
164
169
  end
@@ -6,6 +6,7 @@ require "dependabot/shared_helpers"
6
6
  require "dependabot/errors"
7
7
  require "dependabot/bundler/file_updater"
8
8
  require "dependabot/bundler/native_helpers"
9
+ require "dependabot/bundler/helpers"
9
10
 
10
11
  module Dependabot
11
12
  module Bundler
@@ -64,8 +65,8 @@ module Dependabot
64
65
  ) do |tmp_dir|
65
66
  write_temporary_dependency_files
66
67
 
67
- SharedHelpers.run_helper_subprocess(
68
- command: NativeHelpers.helper_path,
68
+ NativeHelpers.run_bundler_subprocess(
69
+ bundler_version: bundler_version,
69
70
  function: "update_lockfile",
70
71
  args: {
71
72
  gemfile_name: gemfile.name,
@@ -301,6 +302,10 @@ module Dependabot
301
302
 
302
303
  lockfile.content.match?(/BUNDLED WITH\s+2/m)
303
304
  end
305
+
306
+ def bundler_version
307
+ @bundler_version ||= Helpers.bundler_version(lockfile)
308
+ end
304
309
  end
305
310
  end
306
311
  end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Dependabot
4
+ module Bundler
5
+ module Helpers
6
+ V1 = "1"
7
+ V2 = "2"
8
+
9
+ # TODO: Add support for bundler v2
10
+ # return "v2" if lockfile.content.match?(/BUNDLED WITH\s+2/m)
11
+ def self.bundler_version(_lockfile)
12
+ V1
13
+ end
14
+ end
15
+ end
16
+ end
@@ -1,10 +1,39 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "dependabot/shared_helpers"
4
+
3
5
  module Dependabot
4
6
  module Bundler
5
7
  module NativeHelpers
6
- def self.helper_path
7
- "bundle exec ruby #{File.join(native_helpers_root, 'run.rb')}"
8
+ def self.run_bundler_subprocess(function:, args:, bundler_version:)
9
+ SharedHelpers.run_helper_subprocess(
10
+ command: helper_path(bundler_version: bundler_version),
11
+ function: function,
12
+ args: args,
13
+ env: {
14
+ # Bundler will pick the matching installed major version
15
+ "BUNDLER_VERSION" => bundler_version,
16
+ # Force bundler to use the helper Gemfile that has been bundled with
17
+ # v1, otherwise it will point to core's bundler/Gemfile which will
18
+ # be bundled with v2 once it's installed
19
+ "BUNDLE_GEMFILE" => File.join(versioned_helper_path(bundler_version: bundler_version), "Gemfile"),
20
+ # Unset ruby env set by running dependabot-core with bundle exec,
21
+ # forcing bundler to reset them from helpers/v1
22
+ "RUBYLIB" => nil,
23
+ "RUBYOPT" => nil,
24
+ "GEM_PATH" => nil,
25
+ "GEM_HOME" => nil
26
+ }
27
+ )
28
+ end
29
+
30
+ def self.versioned_helper_path(bundler_version:)
31
+ native_helper_version = "v#{bundler_version}"
32
+ File.join(native_helpers_root, native_helper_version)
33
+ end
34
+
35
+ def self.helper_path(bundler_version:)
36
+ "bundle exec ruby #{File.join(versioned_helper_path(bundler_version: bundler_version), 'run.rb')}"
8
37
  end
9
38
 
10
39
  def self.native_helpers_root
@@ -2,6 +2,7 @@
2
2
 
3
3
  require "dependabot/bundler/update_checker"
4
4
  require "dependabot/bundler/native_helpers"
5
+ require "dependabot/bundler/helpers"
5
6
  require "dependabot/shared_helpers"
6
7
 
7
8
  module Dependabot
@@ -28,8 +29,8 @@ module Dependabot
28
29
  # * requirement [String] the requirement on the target_dependency
29
30
  def conflicting_dependencies(dependency:, target_version:)
30
31
  in_a_native_bundler_context(error_handling: false) do |tmp_dir|
31
- SharedHelpers.run_helper_subprocess(
32
- command: NativeHelpers.helper_path,
32
+ NativeHelpers.run_bundler_subprocess(
33
+ bundler_version: bundler_version,
33
34
  function: "conflicting_dependencies",
34
35
  args: {
35
36
  dir: tmp_dir,
@@ -42,6 +43,12 @@ module Dependabot
42
43
  )
43
44
  end
44
45
  end
46
+
47
+ private
48
+
49
+ def bundler_version
50
+ @bundler_version ||= Helpers.bundler_version(lockfile)
51
+ end
45
52
  end
46
53
  end
47
54
  end
@@ -3,6 +3,7 @@
3
3
  require "dependabot/bundler/file_parser"
4
4
  require "dependabot/bundler/file_updater/lockfile_updater"
5
5
  require "dependabot/bundler/native_helpers"
6
+ require "dependabot/bundler/helpers"
6
7
  require "dependabot/bundler/update_checker"
7
8
  require "dependabot/bundler/update_checker/requirements_updater"
8
9
  require "dependabot/errors"
@@ -43,8 +44,8 @@ module Dependabot
43
44
 
44
45
  def force_update
45
46
  in_a_native_bundler_context(error_handling: false) do |tmp_dir|
46
- updated_deps, specs = SharedHelpers.run_helper_subprocess(
47
- command: NativeHelpers.helper_path,
47
+ updated_deps, specs = NativeHelpers.run_bundler_subprocess(
48
+ bundler_version: bundler_version,
48
49
  function: "force_update",
49
50
  args: {
50
51
  dir: tmp_dir,
@@ -146,6 +147,10 @@ module Dependabot
146
147
 
147
148
  lockfile.content.match?(/BUNDLED WITH\s+2/m)
148
149
  end
150
+
151
+ def bundler_version
152
+ @bundler_version ||= Helpers.bundler_version(lockfile)
153
+ end
149
154
  end
150
155
  end
151
156
  end
@@ -1,5 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "dependabot/bundler/native_helpers"
4
+ require "dependabot/bundler/helpers"
5
+
3
6
  module Dependabot
4
7
  module Bundler
5
8
  class UpdateChecker
@@ -53,8 +56,8 @@ module Dependabot
53
56
 
54
57
  SharedHelpers.with_git_configured(credentials: credentials) do
55
58
  in_a_native_bundler_context do |tmp_dir|
56
- SharedHelpers.run_helper_subprocess(
57
- command: NativeHelpers.helper_path,
59
+ NativeHelpers.run_bundler_subprocess(
60
+ bundler_version: bundler_version,
58
61
  function: "depencency_source_latest_git_version",
59
62
  args: {
60
63
  dir: tmp_dir,
@@ -98,8 +101,8 @@ module Dependabot
98
101
  def private_registry_versions
99
102
  @private_registry_versions ||=
100
103
  in_a_native_bundler_context do |tmp_dir|
101
- SharedHelpers.run_helper_subprocess(
102
- command: NativeHelpers.helper_path,
104
+ NativeHelpers.run_bundler_subprocess(
105
+ bundler_version: bundler_version,
103
106
  function: "private_registry_versions",
104
107
  args: {
105
108
  dir: tmp_dir,
@@ -118,8 +121,8 @@ module Dependabot
118
121
  return @source_type = RUBYGEMS unless gemfile
119
122
 
120
123
  @source_type = in_a_native_bundler_context do |tmp_dir|
121
- SharedHelpers.run_helper_subprocess(
122
- command: NativeHelpers.helper_path,
124
+ NativeHelpers.run_bundler_subprocess(
125
+ bundler_version: bundler_version,
123
126
  function: "dependency_source_type",
124
127
  args: {
125
128
  dir: tmp_dir,
@@ -135,6 +138,15 @@ module Dependabot
135
138
  dependency_files.find { |f| f.name == "Gemfile" } ||
136
139
  dependency_files.find { |f| f.name == "gems.rb" }
137
140
  end
141
+
142
+ def lockfile
143
+ dependency_files.find { |f| f.name == "Gemfile.lock" } ||
144
+ dependency_files.find { |f| f.name == "gems.locked" }
145
+ end
146
+
147
+ def bundler_version
148
+ @bundler_version ||= Helpers.bundler_version(lockfile)
149
+ end
138
150
  end
139
151
  end
140
152
  end
@@ -4,6 +4,7 @@ require "excon"
4
4
 
5
5
  require "dependabot/bundler/update_checker"
6
6
  require "dependabot/bundler/native_helpers"
7
+ require "dependabot/bundler/helpers"
7
8
  require "dependabot/shared_helpers"
8
9
  require "dependabot/errors"
9
10
 
@@ -163,8 +164,8 @@ module Dependabot
163
164
 
164
165
  def inaccessible_git_dependencies
165
166
  in_a_native_bundler_context(error_handling: false) do |tmp_dir|
166
- git_specs = SharedHelpers.run_helper_subprocess(
167
- command: NativeHelpers.helper_path,
167
+ git_specs = NativeHelpers.run_bundler_subprocess(
168
+ bundler_version: bundler_version,
168
169
  function: "git_specs",
169
170
  args: {
170
171
  dir: tmp_dir,
@@ -187,8 +188,8 @@ module Dependabot
187
188
 
188
189
  def jfrog_source
189
190
  in_a_native_bundler_context(error_handling: false) do |dir|
190
- SharedHelpers.run_helper_subprocess(
191
- command: NativeHelpers.helper_path,
191
+ NativeHelpers.run_bundler_subprocess(
192
+ bundler_version: bundler_version,
192
193
  function: "jfrog_source",
193
194
  args: {
194
195
  dir: dir,
@@ -236,6 +237,10 @@ module Dependabot
236
237
 
237
238
  lockfile.content.match?(/BUNDLED WITH\s+2/m)
238
239
  end
240
+
241
+ def bundler_version
242
+ @bundler_version ||= Helpers.bundler_version(lockfile)
243
+ end
239
244
  end
240
245
  end
241
246
  end
@@ -2,6 +2,7 @@
2
2
 
3
3
  require "excon"
4
4
 
5
+ require "dependabot/bundler/helpers"
5
6
  require "dependabot/bundler/update_checker"
6
7
  require "dependabot/bundler/file_updater/lockfile_updater"
7
8
  require "dependabot/bundler/requirement"
@@ -75,8 +76,8 @@ module Dependabot
75
76
  # some errors we want to handle specifically ourselves, including
76
77
  # potentially retrying in the case of the Ruby version being locked
77
78
  in_a_native_bundler_context(error_handling: false) do |tmp_dir|
78
- details = SharedHelpers.run_helper_subprocess(
79
- command: NativeHelpers.helper_path,
79
+ details = NativeHelpers.run_bundler_subprocess(
80
+ bundler_version: bundler_version,
80
81
  function: "resolve_version",
81
82
  args: {
82
83
  dependency_name: dependency.name,
@@ -218,6 +219,10 @@ module Dependabot
218
219
 
219
220
  lockfile.content.match?(/BUNDLED WITH\s+2/m)
220
221
  end
222
+
223
+ def bundler_version
224
+ @bundler_version ||= Helpers.bundler_version(lockfile)
225
+ end
221
226
  end
222
227
  end
223
228
  end
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.134.0
4
+ version: 0.134.1
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-01 00:00:00.000000000 Z
11
+ date: 2021-03-02 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.134.0
19
+ version: 0.134.1
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.134.0
26
+ version: 0.134.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: byebug
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -185,18 +185,20 @@ executables: []
185
185
  extensions: []
186
186
  extra_rdoc_files: []
187
187
  files:
188
- - helpers/build
189
- - helpers/lib/functions.rb
190
- - helpers/lib/functions/conflicting_dependency_resolver.rb
191
- - helpers/lib/functions/dependency_source.rb
192
- - helpers/lib/functions/file_parser.rb
193
- - helpers/lib/functions/force_updater.rb
194
- - helpers/lib/functions/lockfile_updater.rb
195
- - helpers/lib/functions/version_resolver.rb
196
- - helpers/monkey_patches/definition_bundler_version_patch.rb
197
- - helpers/monkey_patches/definition_ruby_version_patch.rb
198
- - helpers/monkey_patches/git_source_patch.rb
199
- - helpers/run.rb
188
+ - helpers/v1/.gitignore
189
+ - helpers/v1/Gemfile
190
+ - helpers/v1/build
191
+ - helpers/v1/lib/functions.rb
192
+ - helpers/v1/lib/functions/conflicting_dependency_resolver.rb
193
+ - helpers/v1/lib/functions/dependency_source.rb
194
+ - helpers/v1/lib/functions/file_parser.rb
195
+ - helpers/v1/lib/functions/force_updater.rb
196
+ - helpers/v1/lib/functions/lockfile_updater.rb
197
+ - helpers/v1/lib/functions/version_resolver.rb
198
+ - helpers/v1/monkey_patches/definition_bundler_version_patch.rb
199
+ - helpers/v1/monkey_patches/definition_ruby_version_patch.rb
200
+ - helpers/v1/monkey_patches/git_source_patch.rb
201
+ - helpers/v1/run.rb
200
202
  - lib/dependabot/bundler.rb
201
203
  - lib/dependabot/bundler/file_fetcher.rb
202
204
  - lib/dependabot/bundler/file_fetcher/child_gemfile_finder.rb
@@ -216,6 +218,7 @@ files:
216
218
  - lib/dependabot/bundler/file_updater/lockfile_updater.rb
217
219
  - lib/dependabot/bundler/file_updater/requirement_replacer.rb
218
220
  - lib/dependabot/bundler/file_updater/ruby_requirement_setter.rb
221
+ - lib/dependabot/bundler/helpers.rb
219
222
  - lib/dependabot/bundler/metadata_finder.rb
220
223
  - lib/dependabot/bundler/native_helpers.rb
221
224
  - lib/dependabot/bundler/requirement.rb