Improve handling of short_version starting with version.
This commit is contained in:
parent
91ce799fe2
commit
4f3bfd1d58
@ -261,11 +261,15 @@ module Homebrew
|
|||||||
version_match = version&.match?(/\A\d+(\.\d+)+\Z/)
|
version_match = version&.match?(/\A\d+(\.\d+)+\Z/)
|
||||||
|
|
||||||
if short_version_match && version_match
|
if short_version_match && version_match
|
||||||
return version if version.length > short_version.length && version.start_with?(short_version)
|
return version if version.length > short_version.length && version.start_with?("#{short_version}.")
|
||||||
return short_version if short_version.length > version.length && short_version.start_with?(version)
|
return short_version if short_version.length > version.length && short_version.start_with?("#{version}.")
|
||||||
end
|
end
|
||||||
|
|
||||||
return "#{short_version},#{version}" if short_version&.match?(/\A\d+(\.\d+)*\Z/) && version&.match?(/\A\d+\Z/)
|
if short_version&.match?(/\A\d+(\.\d+)*\Z/) && version&.match?(/\A\d+\Z/)
|
||||||
|
return short_version if short_version.start_with?("#{version}.")
|
||||||
|
|
||||||
|
return "#{short_version},#{version}"
|
||||||
|
end
|
||||||
|
|
||||||
short_version || version
|
short_version || version
|
||||||
end
|
end
|
||||||
|
|||||||
@ -16,6 +16,7 @@ describe "Homebrew.bump_unversioned_casks_args" do
|
|||||||
["1.2.3", "1.2"] => "1.2.3",
|
["1.2.3", "1.2"] => "1.2.3",
|
||||||
["1.2.3", "8312"] => "1.2.3,8312",
|
["1.2.3", "8312"] => "1.2.3,8312",
|
||||||
["2021", "2006"] => "2021,2006",
|
["2021", "2006"] => "2021,2006",
|
||||||
|
["1.0", "1"] => "1.0",
|
||||||
}
|
}
|
||||||
|
|
||||||
expected_mappings.each do |(short_version, version), expected_version|
|
expected_mappings.each do |(short_version, version), expected_version|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user