Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add version detection support for php URL #3262

Merged
merged 2 commits into from
Oct 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions Library/Homebrew/test/version_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,11 @@
.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")
Expand Down
4 changes: 4 additions & 0 deletions Library/Homebrew/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,10 @@ def self._parse(spec)
# 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

Expand Down