Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cask version MAJOR_MINOR_PATCH_REGEX: allow any word character instead of only digits #6820

Merged
merged 1 commit into from Dec 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion Library/Homebrew/cask/dsl/version.rb
Expand Up @@ -11,7 +11,7 @@ class Version < ::String

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

Expand Down
48 changes: 24 additions & 24 deletions Library/Homebrew/test/cask/dsl/version_spec.rb
Expand Up @@ -85,50 +85,50 @@
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
Expand Down