Fix version parsing on URLs with no extensions

This commit is contained in:
Stefano Pigozzi 2015-12-26 19:55:19 +01:00 committed by Mike McQuaid
parent 30455d0fb5
commit e865cee3d3
2 changed files with 8 additions and 0 deletions

View File

@ -361,4 +361,8 @@ class VersionParsingTests < Homebrew::TestCase
assert_version_detected "1.0.2", assert_version_detected "1.0.2",
"https://opam.ocaml.org/archives/easy-format.1.0.2+opam.tar.gz" "https://opam.ocaml.org/archives/easy-format.1.0.2+opam.tar.gz"
end end
def test_waf_version
assert_version_detected "1.8.12", "https://waf.io/waf-1.8.12"
end
end end

View File

@ -307,6 +307,10 @@ class Version
m = /[-_]((?:\d+\.)*\d\.\d+-(?:p|rc|RC)?\d+)(?:[-._](?:bin|dist|stable|src|sources))?$/.match(stem) m = /[-_]((?:\d+\.)*\d\.\d+-(?:p|rc|RC)?\d+)(?:[-._](?:bin|dist|stable|src|sources))?$/.match(stem)
return m.captures.first unless m.nil? return m.captures.first unless m.nil?
# URL with no extension e.g. https://waf.io/waf-1.8.12
m = /-((?:\d+\.)*\d+)$/.match(spec_s)
return m.captures.first unless m.nil?
# e.g. lame-398-1 # e.g. lame-398-1
m = /-((?:\d)+-\d)/.match(stem) m = /-((?:\d)+-\d)/.match(stem)
return m.captures.first unless m.nil? return m.captures.first unless m.nil?