[rubygems/rubygems] Reject unknown platforms when running bundle lock --add-platform

https://github.com/rubygems/rubygems/commit/1f93a2bdc5
This commit is contained in:
David Rodríguez 2024-08-26 16:33:44 +02:00 committed by git
parent 1515353353
commit 6dee0d3fb0
2 changed files with 6 additions and 5 deletions

View File

@ -48,8 +48,8 @@ module Bundler
options["add-platform"].each do |platform_string| options["add-platform"].each do |platform_string|
platform = Gem::Platform.new(platform_string) platform = Gem::Platform.new(platform_string)
if platform.to_s == "unknown" if platform.to_s == "unknown"
Bundler.ui.warn "The platform `#{platform_string}` is unknown to RubyGems " \ Bundler.ui.error "The platform `#{platform_string}` is unknown to RubyGems and can't be added to the lockfile."
"and adding it will likely lead to resolution errors" exit 1
end end
definition.add_platform(platform) definition.add_platform(platform)
end end

View File

@ -857,9 +857,10 @@ RSpec.describe "bundle lock" do
expect(lockfile.platforms).to match_array(default_platform_list("ruby")) expect(lockfile.platforms).to match_array(default_platform_list("ruby"))
end end
it "warns when adding an unknown platform" do it "fails when adding an unknown platform" do
bundle "lock --add-platform foobarbaz" bundle "lock --add-platform foobarbaz", raise_on_error: false
expect(err).to include("The platform `foobarbaz` is unknown to RubyGems and adding it will likely lead to resolution errors") expect(err).to include("The platform `foobarbaz` is unknown to RubyGems and can't be added to the lockfile")
expect(last_command).to be_failure
end end
it "allows removing platforms" do it "allows removing platforms" do