diff --git a/Library/Homebrew/dev-cmd/bump-unversioned-casks.rb b/Library/Homebrew/dev-cmd/bump-unversioned-casks.rb index a65d134fd4..3c45daedbd 100644 --- a/Library/Homebrew/dev-cmd/bump-unversioned-casks.rb +++ b/Library/Homebrew/dev-cmd/bump-unversioned-casks.rb @@ -261,11 +261,15 @@ module Homebrew version_match = version&.match?(/\A\d+(\.\d+)+\Z/) if short_version_match && version_match - 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 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}.") 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 end diff --git a/Library/Homebrew/test/dev-cmd/bump-unversioned-casks_spec.rb b/Library/Homebrew/test/dev-cmd/bump-unversioned-casks_spec.rb index bd6d76dd79..e5929cb9e4 100644 --- a/Library/Homebrew/test/dev-cmd/bump-unversioned-casks_spec.rb +++ b/Library/Homebrew/test/dev-cmd/bump-unversioned-casks_spec.rb @@ -16,6 +16,7 @@ describe "Homebrew.bump_unversioned_casks_args" do ["1.2.3", "1.2"] => "1.2.3", ["1.2.3", "8312"] => "1.2.3,8312", ["2021", "2006"] => "2021,2006", + ["1.0", "1"] => "1.0", } expected_mappings.each do |(short_version, version), expected_version|