dependabot-bundler 0.375.0 → 0.376.0

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: e93ad1b7b9508dac2455f5702b7e25be3d7b9b31ee174e16a179b8a1ab5e7e40
4
- data.tar.gz: 8fe5e19a9305bcabf19a90caf59e00c3373cab545922f51420d812535b1fcf23
3
+ metadata.gz: 1de871ae226d50afe2ee9c43c5d194c97647f59627ace7d9e6385b89f4d3815c
4
+ data.tar.gz: 5ba64cdc7f057d8f030d207ccd0f0d4b0d942ca46941b152a79163b4018add01
5
5
  SHA512:
6
- metadata.gz: 9ad35ac701e3be680672ed62414836daac3116b05c5b32181169c1a35bde247d6428845ffbcaa218fdd88663b411b57ed7873c3884e8e02048dba60f36727f53
7
- data.tar.gz: d47a12316edb81d78c36d84ff103a77597a8149993665d76d1a723c6cacb3e1bd35935c931930cad91eb310872f1a082ca948bbdfcf26f5dcf2b63060494f208
6
+ metadata.gz: 2f6e3f4606609ce3fdf72ce4c1636d8e24eea56947353624ad276b0e20c50180f2e0f530e34eb29aec1a8e8623007ff9072fb67ab0382f45f55fe31156729490
7
+ data.tar.gz: f124fcf4c386db1087d85117913cd634140ba3ab1204114c082c60b4e718420c31e5d5e57d223d753fe6c1167172c4b85b93e0cefe3e5d1e584574f04c036995
data/helpers/v2/build CHANGED
@@ -19,12 +19,27 @@ fi
19
19
 
20
20
  cd "$install_dir"
21
21
 
22
- default_version=$(ruby -rbundler -e'print Bundler::VERSION')
22
+ # Default to Bundler 4, with an override for controlled testing/rollouts.
23
+ bundler_constraint="${DEPENDABOT_BUNDLER_VERSION_CONSTRAINT:-${BUNDLER_VERSION_CONSTRAINT:-~> 4.0}}"
23
24
 
24
25
  export GEM_HOME=$install_dir/.bundle
25
26
 
26
- gem install bundler -v "$default_version" --no-document
27
+ gem install bundler -v "$bundler_constraint" --no-document
28
+
29
+ # Resolve the Bundler version that was actually installed in GEM_HOME to ensure
30
+ # consistency with what was requested and to avoid picking up system gems.
31
+ default_version=$(ruby -e '
32
+ gemspecs = Dir.glob("#{ENV["GEM_HOME"]}/specifications/bundler-*.gemspec")
33
+ latest = gemspecs.max_by { |f| Gem::Version.new(File.basename(f).match(/bundler-(.*)\.gemspec/)[1]) }
34
+ abort("No bundler gemspec found in #{ENV["GEM_HOME"]}/specifications") unless latest
35
+ print File.basename(latest).match(/bundler-(.*)\.gemspec/)[1]
36
+ ')
37
+
38
+ if [ -z "$default_version" ]; then
39
+ echo "error: failed to resolve installed Bundler version in $GEM_HOME" >&2
40
+ exit 1
41
+ fi
27
42
 
28
43
  if [ -z "$DEPENDABOT_NATIVE_HELPERS_PATH" ]; then
29
- bundle install
44
+ bundle _"$default_version"_ install
30
45
  fi
@@ -0,0 +1,25 @@
1
+ # typed: true
2
+ # frozen_string_literal: true
3
+
4
+ # Resolves the Bundler version constraint that the native helper should use
5
+ # at activation time. Honors DEPENDABOT_BUNDLER_VERSION_CONSTRAINT, falling
6
+ # back to BUNDLER_VERSION_CONSTRAINT, and finally to the supplied default.
7
+ #
8
+ # Used by both `run.rb` (for activation via `gem`) and the helper specs so
9
+ # the rollback/staged-rollout behavior is exercised by real code.
10
+ module BundlerVersionConstraint
11
+ DEFAULT_ACTIVATION_CONSTRAINT = ">= 2.4, < 5"
12
+
13
+ def self.resolve(env: ENV, default: DEFAULT_ACTIVATION_CONSTRAINT)
14
+ env.fetch(
15
+ "DEPENDABOT_BUNDLER_VERSION_CONSTRAINT",
16
+ env.fetch("BUNDLER_VERSION_CONSTRAINT", default)
17
+ )
18
+ end
19
+
20
+ # Splits a comma-separated requirement string into the individual clauses
21
+ # accepted by Kernel#gem (e.g. ">= 2.4, < 5" -> [">= 2.4", "< 5"]).
22
+ def self.activation_clauses(constraint)
23
+ constraint.split(",").map(&:strip)
24
+ end
25
+ end
@@ -41,9 +41,10 @@ module Functions
41
41
 
42
42
  bundler_source
43
43
  .fetchers.flat_map do |fetcher|
44
- fetcher
45
- .specs([dependency_name], bundler_source)
46
- .search_all(dependency_name).map(&:version)
44
+ index = fetcher.specs([dependency_name], bundler_source)
45
+ # Bundler 4 removed Index#search_all; use #search which returns all matches
46
+ specs = index.respond_to?(:search_all) ? index.search_all(dependency_name) : index.search(dependency_name)
47
+ specs.map(&:version)
47
48
  end
48
49
  end
49
50
 
@@ -91,11 +91,14 @@ module Functions
91
91
  # Set flags and credentials
92
92
  set_bundler_flags_and_credentials(dir: args.fetch(:dir), credentials: args.fetch(:credentials))
93
93
 
94
- Bundler::Definition.build(args.fetch(:gemfile_name), nil, {})
95
- .send(:sources)
96
- .rubygems_remotes
97
- .find { |uri| uri.host.include?("jfrog") }
98
- &.host
94
+ sources = Bundler::Definition.build(args.fetch(:gemfile_name), nil, {}).send(:sources)
95
+ # Bundler 4 removed SourceList#rubygems_remotes; use rubygems_sources + flat_map(&:remotes)
96
+ remotes = if sources.respond_to?(:rubygems_remotes)
97
+ sources.rubygems_remotes
98
+ else
99
+ sources.rubygems_sources.flat_map(&:remotes)
100
+ end
101
+ remotes.find { |uri| uri.host&.include?("jfrog") }&.host
99
102
  end
100
103
 
101
104
  def self.git_specs(**args)
data/helpers/v2/run.rb CHANGED
@@ -1,7 +1,14 @@
1
1
  # typed: true
2
2
  # frozen_string_literal: true
3
3
 
4
- gem "bundler", "~> 2.4"
4
+ require_relative "lib/bundler_version_constraint"
5
+
6
+ # Allow Bundler 4 by default with an upper bound to prevent unintended future
7
+ # major versions. Honor DEPENDABOT_BUNDLER_VERSION_CONSTRAINT (or its
8
+ # BUNDLER_VERSION_CONSTRAINT fallback) so staged rollouts and emergency
9
+ # rollbacks performed by the build script are respected at activation time.
10
+ bundler_constraint = BundlerVersionConstraint.resolve
11
+ gem "bundler", *BundlerVersionConstraint.activation_clauses(bundler_constraint)
5
12
  require "bundler"
6
13
  require "json"
7
14
 
@@ -0,0 +1,65 @@
1
+ # typed: false
2
+ # frozen_string_literal: true
3
+
4
+ require "native_spec_helper"
5
+ require_relative "../lib/bundler_version_constraint"
6
+
7
+ RSpec.describe BundlerVersionConstraint do
8
+ describe "helper runtime activation" do
9
+ it "is running a supported Bundler major version" do
10
+ # Bundler 3 was intentionally skipped upstream (Bundler jumped from 2.7
11
+ # straight to 4.0 to align with RubyGems) so the supported window is
12
+ # 2.x or 4.x.
13
+ bundler_major = Bundler::VERSION.split(".").first.to_i
14
+ expect(bundler_major).to be_between(2, 4)
15
+ end
16
+ end
17
+
18
+ describe ".resolve" do
19
+ it "returns the DEPENDABOT_BUNDLER_VERSION_CONSTRAINT override when set" do
20
+ env = { "DEPENDABOT_BUNDLER_VERSION_CONSTRAINT" => "~> 2.7" }
21
+ expect(described_class.resolve(env: env)).to eq("~> 2.7")
22
+ end
23
+
24
+ it "prefers DEPENDABOT_BUNDLER_VERSION_CONSTRAINT over BUNDLER_VERSION_CONSTRAINT" do
25
+ env = {
26
+ "DEPENDABOT_BUNDLER_VERSION_CONSTRAINT" => "~> 2.7",
27
+ "BUNDLER_VERSION_CONSTRAINT" => "~> 4.0"
28
+ }
29
+ expect(described_class.resolve(env: env)).to eq("~> 2.7")
30
+ end
31
+
32
+ it "falls back to BUNDLER_VERSION_CONSTRAINT when only that is set" do
33
+ env = { "BUNDLER_VERSION_CONSTRAINT" => "~> 4.0" }
34
+ expect(described_class.resolve(env: env)).to eq("~> 4.0")
35
+ end
36
+
37
+ it "uses the default activation constraint when no env var is set" do
38
+ expect(described_class.resolve(env: {})).to eq(">= 2.4, < 5")
39
+ end
40
+
41
+ it "honours an explicit default override" do
42
+ expect(described_class.resolve(env: {}, default: "~> 4.0")).to eq("~> 4.0")
43
+ end
44
+ end
45
+
46
+ describe ".activation_clauses" do
47
+ it "splits comma-separated requirement strings into trimmed clauses" do
48
+ expect(described_class.activation_clauses(">= 2.4, < 5")).to eq([">= 2.4", "< 5"])
49
+ end
50
+
51
+ it "returns a single clause for a single requirement" do
52
+ expect(described_class.activation_clauses("~> 4.0")).to eq(["~> 4.0"])
53
+ end
54
+ end
55
+
56
+ describe "build script GEM_HOME isolation" do
57
+ it "resolves Bundler version from GEM_HOME only" do
58
+ gem_home = ENV.fetch("GEM_HOME", nil)
59
+ skip "GEM_HOME not set in test environment" unless gem_home
60
+
61
+ bundler_specs = Dir.glob("#{gem_home}/specifications/bundler-*.gemspec")
62
+ expect(bundler_specs.length).to be_positive
63
+ end
64
+ end
65
+ end
@@ -6,6 +6,13 @@ require "webmock/rspec"
6
6
  require "webmock/http_lib_adapters/excon_adapter"
7
7
  require "debug"
8
8
 
9
+ # Bundler 4's stricter $LOAD_PATH handling breaks RSpec's lazy autoload of
10
+ # built-in matchers (e.g. `satisfy`, `raise_error`, `contain_exactly`, `has`).
11
+ # Eagerly load all of them so tests don't hit LoadError mid-run.
12
+ Gem.loaded_specs["rspec-expectations"]&.then do |spec|
13
+ Dir[File.join(spec.full_gem_path, "lib/rspec/matchers/built_in/*.rb")].each { |f| require f }
14
+ end
15
+
9
16
  $LOAD_PATH.unshift(File.expand_path("../lib", __dir__))
10
17
  $LOAD_PATH.unshift(File.expand_path("../monkey_patches", __dir__))
11
18
  $LOAD_PATH.unshift(File.expand_path("../../spec_helpers", __dir__))
@@ -11,8 +11,14 @@ module Dependabot
11
11
  ECOSYSTEM = "bundler"
12
12
  PACKAGE_MANAGER = "bundler"
13
13
 
14
- # Keep versions in ascending order
15
- SUPPORTED_BUNDLER_VERSIONS = T.let([Version.new("2")].freeze, T::Array[Dependabot::Version])
14
+ # Keep versions in ascending order.
15
+ # Note: Bundler 3 was intentionally skipped upstream — Bundler jumped from
16
+ # 2.7 directly to 4.0 to align its major version with RubyGems, so there
17
+ # is no Bundler 3.x release to support.
18
+ SUPPORTED_BUNDLER_VERSIONS = T.let(
19
+ [Version.new("2"), Version.new("4")].freeze,
20
+ T::Array[Dependabot::Version]
21
+ )
16
22
 
17
23
  # Currently, we don't support any deprecated versions of Bundler
18
24
  # When a version is going to be unsupported, it will be added here for a while to give users time to upgrade
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dependabot-bundler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.375.0
4
+ version: 0.376.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dependabot
@@ -15,14 +15,14 @@ dependencies:
15
15
  requirements:
16
16
  - - '='
17
17
  - !ruby/object:Gem::Version
18
- version: 0.375.0
18
+ version: 0.376.0
19
19
  type: :runtime
20
20
  prerelease: false
21
21
  version_requirements: !ruby/object:Gem::Requirement
22
22
  requirements:
23
23
  - - '='
24
24
  - !ruby/object:Gem::Version
25
- version: 0.375.0
25
+ version: 0.376.0
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: parallel
28
28
  requirement: !ruby/object:Gem::Requirement
@@ -259,6 +259,7 @@ files:
259
259
  - helpers/v2/.gitignore
260
260
  - helpers/v2/Gemfile
261
261
  - helpers/v2/build
262
+ - helpers/v2/lib/bundler_version_constraint.rb
262
263
  - helpers/v2/lib/functions.rb
263
264
  - helpers/v2/lib/functions/conflicting_dependency_resolver.rb
264
265
  - helpers/v2/lib/functions/dependency_source.rb
@@ -270,6 +271,7 @@ files:
270
271
  - helpers/v2/monkey_patches/definition_ruby_version_patch.rb
271
272
  - helpers/v2/monkey_patches/git_source_patch.rb
272
273
  - helpers/v2/run.rb
274
+ - helpers/v2/spec/bundler_version_constraint_spec.rb
273
275
  - helpers/v2/spec/functions/conflicting_dependency_resolver_spec.rb
274
276
  - helpers/v2/spec/functions/dependency_source_spec.rb
275
277
  - helpers/v2/spec/functions/file_parser_spec.rb
@@ -322,7 +324,7 @@ licenses:
322
324
  - MIT
323
325
  metadata:
324
326
  bug_tracker_uri: https://github.com/dependabot/dependabot-core/issues
325
- changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.375.0
327
+ changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.376.0
326
328
  rdoc_options: []
327
329
  require_paths:
328
330
  - lib