fallback to exact version if we're not working with a beta
This commit is contained in:
Родитель
4d8a744bcc
Коммит
b6bcd7b22a
|
@ -12,7 +12,7 @@ module MacOS
|
|||
@intended_path = intended_path
|
||||
@download_url = download_url
|
||||
@version = if download_url.empty?
|
||||
latest_xcode_revision(Xcode::Version.new(@semantic_version)).apple
|
||||
latest_xcode_revision(Xcode::Version.new(@semantic_version))
|
||||
else
|
||||
semantic_version
|
||||
end
|
||||
|
@ -38,7 +38,12 @@ module MacOS
|
|||
|
||||
def latest_xcode_revision(xcode_version)
|
||||
requirement = Gem::Dependency.new('Xcode', "~> #{xcode_version}")
|
||||
available_xcodes.select { |v| requirement.match? v.release }.max
|
||||
latest = available_xcodes.select { |v| requirement.match? v.release }.max
|
||||
if latest <= xcode_version
|
||||
latest.apple
|
||||
else
|
||||
available_xcodes.select { |v| v == xcode_version }[0].apple
|
||||
end
|
||||
end
|
||||
|
||||
def installed_path
|
||||
|
@ -138,6 +143,10 @@ module MacOS
|
|||
patch != 0
|
||||
end
|
||||
|
||||
def beta?
|
||||
major_beta_release? || minor_beta_release?
|
||||
end
|
||||
|
||||
def major_beta_release?
|
||||
minor == 'beta'
|
||||
end
|
||||
|
@ -148,13 +157,13 @@ module MacOS
|
|||
|
||||
def apple
|
||||
if major_release?
|
||||
major
|
||||
major.to_s
|
||||
elsif major_beta_release?
|
||||
version.gsub('.', ' ')
|
||||
elsif minor_beta_release?
|
||||
major.to_s + '.' + minor.to_s + (revision.nil? ? ' beta' : ' beta ') + revision.to_s
|
||||
else
|
||||
version
|
||||
version.to_s
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -67,6 +67,7 @@ describe MacOS::Xcode do
|
|||
"11.1\n",
|
||||
"11.2\n",
|
||||
"11.2.1\n",
|
||||
"11.3\n",
|
||||
"11.3 beta\n",
|
||||
"11.3.1\n",
|
||||
"11.4 beta\n",
|
||||
|
@ -98,7 +99,7 @@ describe MacOS::Xcode do
|
|||
xcode = MacOS::Xcode.new('11.6', '/Applications/Xcode.app')
|
||||
expect(xcode.version).to eq '11.6 beta 2'
|
||||
expect(xcode.version).to_not eq '11.6 beta'
|
||||
expect(xcode.version).to_not eq '11.6'
|
||||
expect(xcode.version).to_not eq '11.6 beta2'
|
||||
end
|
||||
it 'returns the name of Xcode 11.5 official when initialized with the semantic version' do
|
||||
xcode = MacOS::Xcode.new('11.5', '/Applications/Xcode.app')
|
||||
|
@ -106,12 +107,6 @@ describe MacOS::Xcode do
|
|||
expect(xcode.version).to_not eq '11.5 beta'
|
||||
expect(xcode.version).to_not eq '11.5 GM Seed'
|
||||
end
|
||||
it 'returns the name of the latest Xcode 11.3 beta when initialized with the semantic version' do
|
||||
xcode = MacOS::Xcode.new('11.3', '/Applications/Xcode.app')
|
||||
expect(xcode.version).to eq '11.3 beta'
|
||||
expect(xcode.version).to_not eq '11.3 beta '
|
||||
expect(xcode.version).to_not eq '11.3'
|
||||
end
|
||||
it 'returns the name of Xcode 10 official when initialized with the semantic version' do
|
||||
xcode = MacOS::Xcode.new('10.0', '/Applications/Xcode.app')
|
||||
expect(xcode.version).to eq '10'
|
||||
|
|
Загрузка…
Ссылка в новой задаче