From 497a160cda986510eefbbe324b15fe0d8f3c3942 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADtor=20Galv=C3=A3o?= <info@vitorgalvao.com> Date: Fri, 6 Dec 2019 15:39:39 +0000 Subject: [PATCH] cask version MAJOR_MINOR_PATCH_REGEX: allow any word character instead of only digits --- Library/Homebrew/cask/dsl/version.rb | 2 +- .../Homebrew/test/cask/dsl/version_spec.rb | 48 +++++++++---------- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/Library/Homebrew/cask/dsl/version.rb b/Library/Homebrew/cask/dsl/version.rb index 29faf0c8ab..477360047e 100644 --- a/Library/Homebrew/cask/dsl/version.rb +++ b/Library/Homebrew/cask/dsl/version.rb @@ -11,7 +11,7 @@ module Cask DIVIDER_REGEX = /(#{DIVIDERS.keys.map { |v| Regexp.quote(v) }.join('|')})/.freeze - MAJOR_MINOR_PATCH_REGEX = /^(\d+)(?:\.(\d+)(?:\.(\d+))?)?/.freeze + MAJOR_MINOR_PATCH_REGEX = /^([^.,:]+)(?:\.([^.,:]+)(?:\.([^.,:]+))?)?/.freeze INVALID_CHARACTERS = /[^0-9a-zA-Z\.\,\:\-\_]/.freeze diff --git a/Library/Homebrew/test/cask/dsl/version_spec.rb b/Library/Homebrew/test/cask/dsl/version_spec.rb index 55271f0dd1..cd1683aedc 100644 --- a/Library/Homebrew/test/cask/dsl/version_spec.rb +++ b/Library/Homebrew/test/cask/dsl/version_spec.rb @@ -85,50 +85,50 @@ describe Cask::DSL::Version, :cask do describe "string manipulation helpers" do describe "#major" do include_examples "version expectations hash", :major, - "1" => "1", - "1.2" => "1", - "1.2.3" => "1", - "1.2.3_4-5" => "1" + "1" => "1", + "1.2" => "1", + "1.2.3" => "1", + "1.2.3-4,5:6" => "1" end describe "#minor" do include_examples "version expectations hash", :minor, - "1" => "", - "1.2" => "2", - "1.2.3" => "2", - "1.2.3_4-5" => "2" + "1" => "", + "1.2" => "2", + "1.2.3" => "2", + "1.2.3-4,5:6" => "2" end describe "#patch" do include_examples "version expectations hash", :patch, - "1" => "", - "1.2" => "", - "1.2.3" => "3", - "1.2.3_4-5" => "3" + "1" => "", + "1.2" => "", + "1.2.3" => "3", + "1.2.3-4,5:6" => "3-4" end describe "#major_minor" do include_examples "version expectations hash", :major_minor, - "1" => "1", - "1.2" => "1.2", - "1.2.3" => "1.2", - "1.2.3_4-5" => "1.2" + "1" => "1", + "1.2" => "1.2", + "1.2.3" => "1.2", + "1.2.3-4,5:6" => "1.2" end describe "#major_minor_patch" do include_examples "version expectations hash", :major_minor_patch, - "1" => "1", - "1.2" => "1.2", - "1.2.3" => "1.2.3", - "1.2.3_4-5" => "1.2.3" + "1" => "1", + "1.2" => "1.2", + "1.2.3" => "1.2.3", + "1.2.3-4,5:6" => "1.2.3-4" end describe "#minor_patch" do include_examples "version expectations hash", :minor_patch, - "1" => "", - "1.2" => "2", - "1.2.3" => "2.3", - "1.2.3_4-5" => "2.3" + "1" => "", + "1.2" => "2", + "1.2.3" => "2.3", + "1.2.3-4,5:6" => "2.3-4" end describe "#before_comma" do -- GitLab