Skip to content

Commit dab1f9a

Browse files
Merge pull request #8482 from rubygems/deivid-rodriguez/fix-legacy-windows-platform-filters
Fix legacy Windows `:platform` values no longer working
2 parents 23047a0 + d6af077 commit dab1f9a

File tree

4 files changed

+46
-39
lines changed

4 files changed

+46
-39
lines changed

bundler/lib/bundler/current_ruby.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ class CurrentRuby
2424
# deprecated
2525
mswin: [Gem::Platform::MSWIN, CurrentRuby::ALL_RUBY_VERSIONS],
2626
mswin64: [Gem::Platform::MSWIN64, CurrentRuby::ALL_RUBY_VERSIONS - [18]],
27-
mingw: [Gem::Platform::MINGW, CurrentRuby::ALL_RUBY_VERSIONS],
28-
x64_mingw: [Gem::Platform::X64_MINGW, CurrentRuby::ALL_RUBY_VERSIONS - [18, 19]],
27+
mingw: [Gem::Platform::UNIVERSAL_MINGW, CurrentRuby::ALL_RUBY_VERSIONS],
28+
x64_mingw: [Gem::Platform::UNIVERSAL_MINGW, CurrentRuby::ALL_RUBY_VERSIONS - [18, 19]],
2929
}.each_with_object({}) do |(platform, spec), hash|
3030
hash[platform] = spec[0]
3131
spec[1]&.each {|version| hash[:"#{platform}_#{version}"] = spec[0] }

bundler/spec/bundler/current_ruby_spec.rb

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -98,38 +98,38 @@
9898
mswin64_33: Gem::Platform::MSWIN64,
9999
mswin64_34: Gem::Platform::MSWIN64,
100100
mswin64_35: Gem::Platform::MSWIN64,
101-
mingw: Gem::Platform::MINGW,
102-
mingw_18: Gem::Platform::MINGW,
103-
mingw_19: Gem::Platform::MINGW,
104-
mingw_20: Gem::Platform::MINGW,
105-
mingw_21: Gem::Platform::MINGW,
106-
mingw_22: Gem::Platform::MINGW,
107-
mingw_23: Gem::Platform::MINGW,
108-
mingw_24: Gem::Platform::MINGW,
109-
mingw_25: Gem::Platform::MINGW,
110-
mingw_26: Gem::Platform::MINGW,
111-
mingw_27: Gem::Platform::MINGW,
112-
mingw_30: Gem::Platform::MINGW,
113-
mingw_31: Gem::Platform::MINGW,
114-
mingw_32: Gem::Platform::MINGW,
115-
mingw_33: Gem::Platform::MINGW,
116-
mingw_34: Gem::Platform::MINGW,
117-
mingw_35: Gem::Platform::MINGW,
118-
x64_mingw: Gem::Platform::X64_MINGW,
119-
x64_mingw_20: Gem::Platform::X64_MINGW,
120-
x64_mingw_21: Gem::Platform::X64_MINGW,
121-
x64_mingw_22: Gem::Platform::X64_MINGW,
122-
x64_mingw_23: Gem::Platform::X64_MINGW,
123-
x64_mingw_24: Gem::Platform::X64_MINGW,
124-
x64_mingw_25: Gem::Platform::X64_MINGW,
125-
x64_mingw_26: Gem::Platform::X64_MINGW,
126-
x64_mingw_27: Gem::Platform::X64_MINGW,
127-
x64_mingw_30: Gem::Platform::X64_MINGW,
128-
x64_mingw_31: Gem::Platform::X64_MINGW,
129-
x64_mingw_32: Gem::Platform::X64_MINGW,
130-
x64_mingw_33: Gem::Platform::X64_MINGW,
131-
x64_mingw_34: Gem::Platform::X64_MINGW,
132-
x64_mingw_35: Gem::Platform::X64_MINGW }
101+
mingw: Gem::Platform::UNIVERSAL_MINGW,
102+
mingw_18: Gem::Platform::UNIVERSAL_MINGW,
103+
mingw_19: Gem::Platform::UNIVERSAL_MINGW,
104+
mingw_20: Gem::Platform::UNIVERSAL_MINGW,
105+
mingw_21: Gem::Platform::UNIVERSAL_MINGW,
106+
mingw_22: Gem::Platform::UNIVERSAL_MINGW,
107+
mingw_23: Gem::Platform::UNIVERSAL_MINGW,
108+
mingw_24: Gem::Platform::UNIVERSAL_MINGW,
109+
mingw_25: Gem::Platform::UNIVERSAL_MINGW,
110+
mingw_26: Gem::Platform::UNIVERSAL_MINGW,
111+
mingw_27: Gem::Platform::UNIVERSAL_MINGW,
112+
mingw_30: Gem::Platform::UNIVERSAL_MINGW,
113+
mingw_31: Gem::Platform::UNIVERSAL_MINGW,
114+
mingw_32: Gem::Platform::UNIVERSAL_MINGW,
115+
mingw_33: Gem::Platform::UNIVERSAL_MINGW,
116+
mingw_34: Gem::Platform::UNIVERSAL_MINGW,
117+
mingw_35: Gem::Platform::UNIVERSAL_MINGW,
118+
x64_mingw: Gem::Platform::UNIVERSAL_MINGW,
119+
x64_mingw_20: Gem::Platform::UNIVERSAL_MINGW,
120+
x64_mingw_21: Gem::Platform::UNIVERSAL_MINGW,
121+
x64_mingw_22: Gem::Platform::UNIVERSAL_MINGW,
122+
x64_mingw_23: Gem::Platform::UNIVERSAL_MINGW,
123+
x64_mingw_24: Gem::Platform::UNIVERSAL_MINGW,
124+
x64_mingw_25: Gem::Platform::UNIVERSAL_MINGW,
125+
x64_mingw_26: Gem::Platform::UNIVERSAL_MINGW,
126+
x64_mingw_27: Gem::Platform::UNIVERSAL_MINGW,
127+
x64_mingw_30: Gem::Platform::UNIVERSAL_MINGW,
128+
x64_mingw_31: Gem::Platform::UNIVERSAL_MINGW,
129+
x64_mingw_32: Gem::Platform::UNIVERSAL_MINGW,
130+
x64_mingw_33: Gem::Platform::UNIVERSAL_MINGW,
131+
x64_mingw_34: Gem::Platform::UNIVERSAL_MINGW,
132+
x64_mingw_35: Gem::Platform::UNIVERSAL_MINGW }
133133
end
134134
# rubocop:enable Naming/VariableNumber
135135

bundler/spec/commands/cache_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@
211211
end
212212

213213
context "with --all-platforms" do
214-
it "puts the gems in vendor/cache even for other rubies", bundler: ">= 2.4.0" do
214+
it "puts the gems in vendor/cache even for other rubies" do
215215
gemfile <<-D
216216
source "https://gem.repo1"
217217
gem 'myrack', :platforms => [:ruby_20, :windows_20]
@@ -221,7 +221,7 @@
221221
expect(bundled_app("vendor/cache/myrack-1.0.0.gem")).to exist
222222
end
223223

224-
it "puts the gems in vendor/cache even for legacy windows rubies", bundler: ">= 2.4.0" do
224+
it "puts the gems in vendor/cache even for legacy windows rubies" do
225225
gemfile <<-D
226226
source "https://gem.repo1"
227227
gem 'myrack', :platforms => [:ruby_20, :x64_mingw_20]

bundler/spec/support/filters.rb

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
# frozen_string_literal: true
22

33
class RequirementChecker < Proc
4-
def self.against(present)
4+
def self.against(present, major_only: false)
5+
present = present.split(".")[0] if major_only
56
provided = Gem::Version.new(present)
67

78
new do |required|
8-
!Gem::Requirement.new(required).satisfied_by?(provided)
9+
requirement = Gem::Requirement.new(required)
10+
11+
if major_only && !requirement.requirements.map(&:last).all? {|version| version.segments.one? }
12+
raise "this filter only supports major versions, but #{required} was given"
13+
end
14+
15+
!requirement.satisfied_by?(provided)
916
end.tap do |checker|
1017
checker.provided = provided
1118
end
@@ -21,7 +28,7 @@ def inspect
2128
RSpec.configure do |config|
2229
config.filter_run_excluding realworld: true
2330

24-
config.filter_run_excluding bundler: RequirementChecker.against(Bundler::VERSION.split(".")[0])
31+
config.filter_run_excluding bundler: RequirementChecker.against(Bundler::VERSION, major_only: true)
2532
config.filter_run_excluding rubygems: RequirementChecker.against(Gem::VERSION)
2633
config.filter_run_excluding ruby_repo: !ENV["GEM_COMMAND"].nil?
2734
config.filter_run_excluding no_color_tty: Gem.win_platform? || !ENV["GITHUB_ACTION"].nil?

0 commit comments

Comments
 (0)