Improve dash separated version detection.

* Also with test case.

Closes Homebrew/homebrew#47584.

Signed-off-by: Baptiste Fontaine <batifon@yahoo.fr>
This commit is contained in:
Xiyue Deng 2016-01-01 02:29:41 -08:00 committed by Baptiste Fontaine
parent c6f45a9e06
commit e1dfafa54c
2 changed files with 5 additions and 1 deletions

View File

@ -365,4 +365,8 @@ class VersionParsingTests < Homebrew::TestCase
def test_waf_version
assert_version_detected "1.8.12", "https://waf.io/waf-1.8.12"
end
def test_dash_separated_version
assert_version_detected "6-20151227", "ftp://gcc.gnu.org/pub/gcc/snapshots/6-20151227/gcc-6-20151227.tar.bz2"
end
end

View File

@ -312,7 +312,7 @@ class Version
return m.captures.first unless m.nil?
# e.g. lame-398-1
m = /-((?:\d)+-\d)/.match(stem)
m = /-((?:\d)+-\d+)/.match(stem)
return m.captures.first unless m.nil?
# e.g. foobar-4.5.1