Skip to content

Commit 6f397af

Browse files
hsbtclaude
andcommitted
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. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 93b1c5b commit 6f397af

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

bundler/lib/bundler/definition.rb

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,20 @@ def resolver
635635
end
636636

637637
def expanded_dependencies
638-
dependencies_with_bundler + metadata_dependencies
638+
apply_overrides_to(dependencies_with_bundler) + metadata_dependencies
639+
end
640+
641+
def apply_overrides_to(deps)
642+
return deps if @overrides.empty?
643+
deps.map {|dep| apply_override_to(dep) }
644+
end
645+
646+
def apply_override_to(dep)
647+
override = @overrides.find {|o| o.target == dep.name && o.field == :version }
648+
return dep unless override
649+
new_dep = dep.dup
650+
new_dep.instance_variable_set(:@requirement, override.apply_to(dep.requirement))
651+
new_dep
639652
end
640653

641654
def dependencies_with_bundler

0 commit comments

Comments
 (0)