[rubygems/rubygems] Don't remove existing platform gems when PLATFORMS section is badly indented

https://github.com/rubygems/rubygems/commit/ec099ebf1e
This commit is contained in:
David Rodríguez 2024-08-02 22:24:42 +02:00 коммит произвёл git
Родитель 540bcf5248
Коммит 3005ed6816
2 изменённых файлов: 61 добавлений и 1 удалений

Просмотреть файл

@ -272,7 +272,7 @@ module Bundler
end
def parse_platform(line)
@platforms << Gem::Platform.new($1) if line =~ /^ (.*)$/
@platforms << Gem::Platform.new($1.strip) if line =~ /^ (.*)$/
end
def parse_bundled_with(line)

Просмотреть файл

@ -1990,4 +1990,64 @@ RSpec.describe "bundle lock" do
L
end
end
context "when lockfile has incorrectly indented platforms" do
before do
build_repo4 do
build_gem "ffi", "1.1.0" do |s|
s.platform = "x86_64-linux"
end
build_gem "ffi", "1.1.0" do |s|
s.platform = "arm64-darwin"
end
end
gemfile <<~G
source "https://gem.repo4"
gem "ffi"
G
lockfile <<~L
GEM
remote: https://gem.repo4/
specs:
ffi (1.1.0-arm64-darwin)
PLATFORMS
arm64-darwin
DEPENDENCIES
ffi
BUNDLED WITH
#{Bundler::VERSION}
L
end
it "does not remove any gems" do
simulate_platform "x86_64-linux" do
bundle "lock --update"
end
expect(lockfile).to eq <<~L
GEM
remote: https://gem.repo4/
specs:
ffi (1.1.0-arm64-darwin)
ffi (1.1.0-x86_64-linux)
PLATFORMS
arm64-darwin
x86_64-linux
DEPENDENCIES
ffi
BUNDLED WITH
#{Bundler::VERSION}
L
end
end
end