Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ releases.

### The following bundled gems are updated.

* minitest 6.0.3
* minitest 6.0.4
* rake 13.4.1
* 13.3.1 to [v13.4.0][rake-v13.4.0], [v13.4.1][rake-v13.4.1]
* test-unit 3.7.7
* 3.7.5 to [3.7.6][test-unit-3.7.6], [3.7.7][test-unit-3.7.7]
* net-imap 0.6.3
Expand Down Expand Up @@ -182,6 +184,8 @@ A lot of work has gone into making Ractors more stable, performant, and usable.
[resolv-v0.7.1]: https://github.com/ruby/resolv/releases/tag/v0.7.1
[strscan-v3.1.7]: https://github.com/ruby/strscan/releases/tag/v3.1.7
[timeout-v0.6.1]: https://github.com/ruby/timeout/releases/tag/v0.6.1
[rake-v13.4.0]: https://github.com/ruby/rake/releases/tag/v13.4.0
[rake-v13.4.1]: https://github.com/ruby/rake/releases/tag/v13.4.1
[test-unit-3.7.6]: https://github.com/test-unit/test-unit/releases/tag/3.7.6
[test-unit-3.7.7]: https://github.com/test-unit/test-unit/releases/tag/3.7.7
[net-imap-v0.6.3]: https://github.com/ruby/net-imap/releases/tag/v0.6.3
Expand Down
4 changes: 2 additions & 2 deletions gems/bundled_gems
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
# - revision: revision in repository-url to test
# if `revision` is not given, "v"+`version` or `version` will be used.

minitest 6.0.3 https://github.com/minitest/minitest
minitest 6.0.4 https://github.com/minitest/minitest
power_assert 3.0.1 https://github.com/ruby/power_assert
rake 13.3.1 https://github.com/ruby/rake
rake 13.4.1 https://github.com/ruby/rake
test-unit 3.7.7 https://github.com/test-unit/test-unit
rexml 3.4.4 https://github.com/ruby/rexml
rss 0.3.2 https://github.com/ruby/rss
Expand Down
20 changes: 19 additions & 1 deletion lib/bundler/definition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,25 @@ def start_resolution
end

def precompute_source_requirements_for_indirect_dependencies?
sources.non_global_rubygems_sources.all?(&:dependency_api_available?)
if sources.non_global_rubygems_sources.all?(&:dependency_api_available?)
true
else
non_dependency_api_warning
false
end
end

def non_dependency_api_warning
non_api_sources = sources.non_global_rubygems_sources.reject(&:dependency_api_available?)
non_api_source_names = non_api_sources.map {|d| " * #{d}" }.join("\n")

msg = String.new
msg << "Your Gemfile contains scoped sources that don't implement a dependency API, namely:\n\n"
msg << non_api_source_names
msg << "\n\nUsing 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."
Bundler.ui.warn msg
end

def current_platform_locked?
Expand Down
51 changes: 51 additions & 0 deletions spec/bundler/bundler/definition_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,57 @@
end
end

describe "#precompute_source_requirements_for_indirect_dependencies?" do
before do
allow(Bundler::SharedHelpers).to receive(:find_gemfile) { Pathname.new("Gemfile") }
end

let(:sources) { Bundler::SourceList.new }
subject { Bundler::Definition.new(nil, [], sources, []) }

before do
allow(sources).to receive(:non_global_rubygems_sources).and_return(non_global_rubygems_sources)
end

context "when all the scoped sources implement a dependency API" do
let(:non_global_rubygems_sources) do
[
double("non-global-source-0", "dependency_api_available?":true, to_s:"a"),
double("non-global-source-1", "dependency_api_available?":true, to_s:"b"),
]
end

it "returns true without warning" do
expect(subject).not_to receive(:non_dependency_api_warning)

expect(subject.send(:precompute_source_requirements_for_indirect_dependencies?)).to be_truthy
end
end

context "when some scoped sources do not implement a dependency API" do
let(:non_global_rubygems_sources) do
[
double("non-global-source-0", "dependency_api_available?":true, to_s:"a"),
double("non-global-source-1", "dependency_api_available?":false, to_s:"b"),
double("non-global-source-2", "dependency_api_available?":false, to_s:"c"),
]
end

it "returns false and warns about the non-API sources" do
expect(Bundler.ui).to receive(:warn).with(<<-W.strip)
Your Gemfile contains scoped sources that don't implement a dependency API, namely:

* b
* c

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.
W

expect(subject.send(:precompute_source_requirements_for_indirect_dependencies?)).to be_falsy
end
end
end

def mock_source_list
Class.new do
def all_sources
Expand Down