Skip to content

Commit 1b1ddae

Browse files
committed
Fixes xcode version finder
It was finding a beta version despite the release one being already available (11.4 beta instead of 11.4). Now it tries to match the name first and when nothing matches it falls back to matching version. Resolves xcpretty/xcode-install#381 Solution proposed here: xcpretty/xcode-install#381 (comment).
1 parent 5e0e387 commit 1b1ddae

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

lib/xcode/install.rb

+4
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,12 @@ def find_xcode_version(version)
168168

169169
seedlist.each do |current_seed|
170170
return current_seed if current_seed.name == version
171+
end
172+
173+
seedlist.each do |current_seed|
171174
return current_seed if parsed_version && current_seed.version == parsed_version
172175
end
176+
173177
nil
174178
end
175179

spec/installer_spec.rb

+20
Original file line numberDiff line numberDiff line change
@@ -98,4 +98,24 @@ module XcodeInstall
9898
percentages.count.should.be.close(8, 4)
9999
end
100100
end
101+
102+
describe '#find_xcode_version' do
103+
it 'should find the one with the matching name' do
104+
installer = Installer.new
105+
106+
xcodes = [
107+
XcodeInstall::Xcode.new('name' => '11.4 beta 2',
108+
'files' => [{
109+
'remotePath' => '/Developer_Tools/Xcode_11.4_beta_2/Xcode_11.4_beta_2.xip'
110+
}]),
111+
XcodeInstall::Xcode.new('name' => '11.4',
112+
'files' => [{
113+
'remotePath' => '/Developer_Tools/Xcode_11.4/Xcode_11.4.xip'
114+
}])
115+
]
116+
117+
installer.stubs(:fetch_seedlist).returns(xcodes)
118+
installer.find_xcode_version("11.4").name.should.be.equal("11.4")
119+
end
120+
end
101121
end

0 commit comments

Comments
 (0)