Fix version mapping.
This commit is contained in:
parent
e416668a25
commit
05b496194a
@ -16,6 +16,7 @@ describe Homebrew::UnversionedCaskChecker do
|
|||||||
["1.0", "1"] => "1.0",
|
["1.0", "1"] => "1.0",
|
||||||
["1.0", "0"] => "1.0",
|
["1.0", "0"] => "1.0",
|
||||||
["1.2.3.4000", "4000"] => "1.2.3.4000",
|
["1.2.3.4000", "4000"] => "1.2.3.4000",
|
||||||
|
["5", "5.0.45"] => "5.0.45",
|
||||||
}
|
}
|
||||||
|
|
||||||
expected_mappings.each do |(short_version, version), expected_version|
|
expected_mappings.each do |(short_version, version), expected_version|
|
||||||
|
|||||||
@ -72,18 +72,15 @@ module Homebrew
|
|||||||
def self.decide_between_versions(short_version, version)
|
def self.decide_between_versions(short_version, version)
|
||||||
return short_version if short_version == version
|
return short_version if short_version == version
|
||||||
|
|
||||||
short_version_match = short_version&.match?(/\A\d+(\.\d+)+\Z/)
|
if short_version && version
|
||||||
version_match = version&.match?(/\A\d+(\.\d+)+\Z/)
|
return version if version.match?(/\A\d+(\.\d+)+\Z/) && version.start_with?("#{short_version}.")
|
||||||
|
return short_version if short_version.match?(/\A\d+(\.\d+)+\Z/) && short_version.start_with?("#{version}.")
|
||||||
|
|
||||||
if short_version_match && version_match
|
if short_version.match?(/\A\d+(\.\d+)*\Z/) && version.match?(/\A\d+\Z/)
|
||||||
return version if version.length > short_version.length && version.start_with?("#{short_version}.")
|
return short_version if short_version.start_with?("#{version}.") || short_version.end_with?(".#{version}")
|
||||||
return short_version if short_version.length > version.length && short_version.start_with?("#{version}.")
|
|
||||||
end
|
|
||||||
|
|
||||||
if short_version&.match?(/\A\d+(\.\d+)*\Z/) && version&.match?(/\A\d+\Z/)
|
return "#{short_version},#{version}"
|
||||||
return short_version if short_version.start_with?("#{version}.") || short_version.end_with?(".#{version}")
|
end
|
||||||
|
|
||||||
return "#{short_version},#{version}"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
short_version || version
|
short_version || version
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user