version: parse tag if detecting version

This commit is contained in:
Seeker 2020-02-27 10:27:02 -08:00
parent 955947c8dc
commit 11ebc27e0a
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