version: correctly parse codeload URLs

Needed for Homebrew/homebrew#49346.

Closes Homebrew/homebrew#49354.

Signed-off-by: Alex Dunn <dunn.alex@gmail.com>
This commit is contained in:
Alex Dunn 2016-02-19 11:11:14 -08:00 committed by Alex Dunn
parent b54d477416
commit f15532452e
2 changed files with 8 additions and 2 deletions

View File

@ -189,6 +189,10 @@ class VersionParsingTests < Homebrew::TestCase
assert_version_detected "1.1.4", "https://github.com/sam-github/libnet/tarball/libnet-1.1.4"
end
def test_codeload_style
assert_version_detected "0.7.1", "https://codeload.github.com/gsamokovarov/jump/tar.gz/v0.7.1"
end
def test_gloox_beta_style
assert_version_detected "1.0-beta7", "http://camaya.net/download/gloox-1.0-beta7.tar.bz2"
end

View File

@ -307,8 +307,10 @@ class Version
m = /[-_]((?:\d+\.)*\d\.\d+-(?:p|rc|RC)?\d+)(?:[-._](?:bin|dist|stable|src|sources))?$/.match(stem)
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)
# URL with no extension
# e.g. https://waf.io/waf-1.8.12
# e.g. https://codeload.github.com/gsamokovarov/jump/tar.gz/v0.7.1
m = /[-v]((?:\d+\.)*\d+)$/.match(spec_s)
return m.captures.first unless m.nil?
# e.g. lame-398-1