Skip to content

Commit ddd292a

Browse files
hsbtclaude
andcommitted
Remove extra guard conditions to preserve existing behavior
The original PR added @Remote and aggregate_global_source? checks to precompute_source_requirements_for_indirect_dependencies?, but these conditions did not exist in the current codebase and would change the method's behavior in cases where @Remote is false or aggregate_global_source? is true. Since the goal is only to warn when falling back to the insecure aggregate resolution path, keep the existing condition as-is and just add the warning on the false branch. Simplify the corresponding tests accordingly. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 403d674 commit ddd292a

2 files changed

Lines changed: 26 additions & 32 deletions

File tree

bundler/lib/bundler/definition.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -777,8 +777,6 @@ def start_resolution
777777
end
778778

779779
def precompute_source_requirements_for_indirect_dependencies?
780-
return false unless @remote && !sources.aggregate_global_source?
781-
782780
if sources.non_global_rubygems_sources.all?(&:dependency_api_available?)
783781
true
784782
else

spec/bundler/definition_spec.rb

Lines changed: 26 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -297,49 +297,45 @@
297297
let(:sources) { Bundler::SourceList.new }
298298
subject { Bundler::Definition.new(nil, [], sources, []) }
299299

300-
context "when remote and does not have multiple global sources" do
301-
before do
302-
subject.instance_variable_set(:@remote, true)
303-
allow(sources).to receive(:aggregate_global_source?).and_return(false)
304-
allow(sources).to receive(:non_global_rubygems_sources).and_return(non_global_rubygems_sources)
305-
end
300+
before do
301+
allow(sources).to receive(:non_global_rubygems_sources).and_return(non_global_rubygems_sources)
302+
end
306303

307-
context "when all the scoped sources contain a dependency API" do
308-
let(:non_global_rubygems_sources) do
309-
[
310-
double("non-global-source-0", :dependency_api_available? => true, :to_s => "a"),
311-
double("non-global-source-1", :dependency_api_available? => true, :to_s => "b"),
312-
]
313-
end
304+
context "when all the scoped sources implement a dependency API" do
305+
let(:non_global_rubygems_sources) do
306+
[
307+
double("non-global-source-0", :dependency_api_available? => true, :to_s => "a"),
308+
double("non-global-source-1", :dependency_api_available? => true, :to_s => "b"),
309+
]
310+
end
314311

315-
it "will not raise a warning" do
316-
expect(subject).not_to receive(:non_dependency_api_warning)
312+
it "returns true without warning" do
313+
expect(subject).not_to receive(:non_dependency_api_warning)
317314

318-
expect(subject.send(:precompute_source_requirements_for_indirect_dependencies?)).to be_truthy
319-
end
315+
expect(subject.send(:precompute_source_requirements_for_indirect_dependencies?)).to be_truthy
320316
end
317+
end
321318

322-
context "when scoped sources do not contain a dependency API" do
323-
let(:non_global_rubygems_sources) do
324-
[
325-
double("non-global-source-0", :dependency_api_available? => true, :to_s => "a"),
326-
double("non-global-source-1", :dependency_api_available? => false, :to_s => "b"),
327-
double("non-global-source-2", :dependency_api_available? => false, :to_s => "c"),
328-
]
329-
end
319+
context "when some scoped sources do not implement a dependency API" do
320+
let(:non_global_rubygems_sources) do
321+
[
322+
double("non-global-source-0", :dependency_api_available? => true, :to_s => "a"),
323+
double("non-global-source-1", :dependency_api_available? => false, :to_s => "b"),
324+
double("non-global-source-2", :dependency_api_available? => false, :to_s => "c"),
325+
]
326+
end
330327

331-
it "will raise a warning" do
332-
expect(Bundler.ui).to receive(:warn).with(<<-W.strip)
328+
it "returns false and warns about the non-API sources" do
329+
expect(Bundler.ui).to receive(:warn).with(<<-W.strip)
333330
Your Gemfile contains scoped sources that don't implement a dependency API, namely:
334331
335332
* b
336333
* c
337334
338335
Using the above gem servers may result in installing unexpected gems. To resolve this warning, make sure you use gem servers that implement dependency APIs, such as gemstash or geminabox gem servers.
339-
W
336+
W
340337

341-
expect(subject.send(:precompute_source_requirements_for_indirect_dependencies?)).to be_falsy
342-
end
338+
expect(subject.send(:precompute_source_requirements_for_indirect_dependencies?)).to be_falsy
343339
end
344340
end
345341
end

0 commit comments

Comments
 (0)