version: parse opam archives

Closes Homebrew/homebrew#44544.

Signed-off-by: Baptiste Fontaine <batifon@yahoo.fr>
This commit is contained in:
Baptiste Fontaine 2015-10-02 22:52:25 +02:00
parent 5f29dee138
commit cc7a047edc
2 changed files with 18 additions and 0 deletions

View File

@ -350,4 +350,15 @@ class VersionParsingTests < Homebrew::TestCase
assert_version_detected "4.0.18", assert_version_detected "4.0.18",
"http://ftpmirror.gnu.org/mtools/mtools_4.0.18_i386.deb" "http://ftpmirror.gnu.org/mtools/mtools_4.0.18_i386.deb"
end end
def test_opam_version
assert_version_detected "2.18.3",
"https://opam.ocaml.org/archives/lablgtk.2.18.3+opam.tar.gz"
assert_version_detected "1.9",
"https://opam.ocaml.org/archives/sha.1.9+opam.tar.gz"
assert_version_detected "0.99.2",
"https://opam.ocaml.org/archives/ppx_tools.0.99.2+opam.tar.gz"
assert_version_detected "1.0.2",
"https://opam.ocaml.org/archives/easy-format.1.0.2+opam.tar.gz"
end
end end

View File

@ -328,6 +328,13 @@ class Version
m = /-(\d+\.\d+(?:\.\d+)?)-w(?:in)?(?:32|64)$/.match(stem) m = /-(\d+\.\d+(?:\.\d+)?)-w(?:in)?(?:32|64)$/.match(stem)
return m.captures.first unless m.nil? return m.captures.first unless m.nil?
# Opam packages
# e.g. https://opam.ocaml.org/archives/sha.1.9+opam.tar.gz
# e.g. https://opam.ocaml.org/archives/lablgtk.2.18.3+opam.tar.gz
# e.g. https://opam.ocaml.org/archives/easy-format.1.0.2+opam.tar.gz
m = /\.(\d+\.\d+(?:\.\d+)?)\+opam$/.match(stem)
return m.captures.first unless m.nil?
# e.g. http://ftpmirror.gnu.org/mtools/mtools-4.0.18-1.i686.rpm # e.g. http://ftpmirror.gnu.org/mtools/mtools-4.0.18-1.i686.rpm
# e.g. http://ftpmirror.gnu.org/autogen/autogen-5.5.7-5.i386.rpm # e.g. http://ftpmirror.gnu.org/autogen/autogen-5.5.7-5.i386.rpm
# e.g. http://ftpmirror.gnu.org/libtasn1/libtasn1-2.8-x86.zip # e.g. http://ftpmirror.gnu.org/libtasn1/libtasn1-2.8-x86.zip