Merge pull request #7088 from SeekingMeaning/version

version: parse tag if detecting version
This commit is contained in:
Mike McQuaid 2020-02-27 19:29:33 +00:00 committed by GitHub
commit f37cd18e1a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View File

@ -684,10 +684,15 @@ describe Version do
.to be_detected_from("https://php.net/get/php-7.1.10.tar.gz/from/this/mirror") .to be_detected_from("https://php.net/get/php-7.1.10.tar.gz/from/this/mirror")
end end
specify "from URL" do specify "from tag" do
expect(described_class.create("1.2.3")) expect(described_class.create("1.2.3"))
.to be_detected_from("https://github.com/foo/bar.git", tag: "v1.2.3") .to be_detected_from("https://github.com/foo/bar.git", tag: "v1.2.3")
end end
specify "beta from tag" do
expect(described_class.create("1.2.3-beta1"))
.to be_detected_from("https://github.com/foo/bar.git", tag: "v1.2.3-beta1")
end
end end
end end

View File

@ -201,7 +201,7 @@ class Version
def self.detect(url, specs) def self.detect(url, specs)
if specs.key?(:tag) if specs.key?(:tag)
FromURL.new(specs[:tag][/((?:\d+\.)*\d+)/, 1]) FromURL.parse(specs[:tag])
else else
FromURL.parse(url) FromURL.parse(url)
end end