summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHiroshi SHIBATA <hsbt@ruby-lang.org>2026-05-01 12:37:10 +0900
committergit <svn-admin@ruby-lang.org>2026-05-07 09:24:53 +0000
commit2da7365ff6f2f15b7ac72eef214c8be8d1cc5ea8 (patch)
treef4772bc00f5d5f48283a6c8ade5a7772497cb025
parent464e212b961164e3730b17119a1f79b3dac7f2f9 (diff)
[ruby/rubygems] Apply override at Definition level for direct dependencies
The Resolver-only hook reshapes deps just before PubGrub sees them, but it does not influence the Bundler::Dependency objects fed into Definition#expanded_dependencies. As a result the Resolver::Package built from each direct dep keeps the original requirement, so its prerelease policy and (in later commits) lockfile change detection ignore the override entirely. Apply the override to direct deps at expanded_dependencies as well so that Package metadata and convergence see the effective requirement; the Resolver hook remains responsible for transitive deps fetched from gemspecs. https://github.com/ruby/rubygems/commit/6f397af4cc Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
-rw-r--r--lib/bundler/definition.rb15
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb
index 523e6ff448..1308b41563 100644
--- a/lib/bundler/definition.rb
+++ b/lib/bundler/definition.rb
@@ -635,7 +635,20 @@ module Bundler
end
def expanded_dependencies
- dependencies_with_bundler + metadata_dependencies
+ apply_overrides_to(dependencies_with_bundler) + metadata_dependencies
+ end
+
+ def apply_overrides_to(deps)
+ return deps if @overrides.empty?
+ deps.map {|dep| apply_override_to(dep) }
+ end
+
+ def apply_override_to(dep)
+ override = @overrides.find {|o| o.target == dep.name && o.field == :version }
+ return dep unless override
+ new_dep = dep.dup
+ new_dep.instance_variable_set(:@requirement, override.apply_to(dep.requirement))
+ new_dep
end
def dependencies_with_bundler