Merge pull request #3262 from kabel/version-detect-php

Add version detection support for php URL
This commit is contained in:
Mike McQuaid 2017-10-06 04:34:12 +01:00 committed by GitHub
commit dd2083d03d
2 changed files with 9 additions and 0 deletions

View File

@ -649,6 +649,11 @@ describe Version do
.to be_detected_from("ftp://gcc.gnu.org/pub/gcc/snapshots/6-20151227/gcc-6-20151227.tar.bz2")
end
specify "semver in middle of URL" do
expect(Version.create("7.1.10"))
.to be_detected_from("https://php.net/get/php-7.1.10.tar.gz/from/this/mirror")
end
specify "from URL" do
expect(Version.create("1.2.3"))
.to be_detected_from("http://github.com/foo/bar.git", tag: "v1.2.3")

View File

@ -456,6 +456,10 @@ class Version
# e.g. http://www.ijg.org/files/jpegsrc.v8d.tar.gz
m = /\.v(\d+[a-z]?)/.match(stem)
return m.captures.first unless m.nil?
# e.g. https://secure.php.net/get/php-7.1.10.tar.bz2/from/this/mirror
m = /[-.vV]?((?:\d+\.)+\d+(?:[-_.]?(?i:alpha|beta|pre|rc)\.?\d{,2})?)/.match(spec_s)
return m.captures.first unless m.nil?
end
end