diff options
author | Luis Rascão <luis.rascao@gmail.com> | 2016-02-14 23:40:35 +0000 |
---|---|---|
committer | Luis Rascão <luis.rascao@gmail.com> | 2016-02-15 00:05:07 +0000 |
commit | bffc73d0eef22b4d777049b2ed1a339e3402f61b (patch) | |
tree | 7bc48e4b9ba11497796fcead63a188a769273d5f /src | |
parent | a64cd50ae187fe5a8e82ab7ac38b5621629dd394 (diff) | |
download | rebar-bffc73d0eef22b4d777049b2ed1a339e3402f61b.tar.gz |
Update regexp to account for newer OTP versions
Add support for patch numbers, also expose
version_tuple/1 for easier internal access.
Normalize version_tuple/1 return value, now
always {Major, Minor, Patch}.
Update regression tests accordingly.
Diffstat (limited to 'src')
-rw-r--r-- | src/rebar_require_vsn.erl | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/src/rebar_require_vsn.erl b/src/rebar_require_vsn.erl index 5eecf74..684578a 100644 --- a/src/rebar_require_vsn.erl +++ b/src/rebar_require_vsn.erl @@ -31,7 +31,8 @@ -include("rebar.hrl"). -export([compile/2, - eunit/2]). + eunit/2, + version_tuple/1]). %% for internal use only -export([info/2, @@ -103,12 +104,12 @@ check_versions(Config) -> case rebar_config:get(Config, require_min_otp_vsn, undefined) of undefined -> ?DEBUG("Min OTP version unconfigured~n", []); MinOtpVsn -> - {MinMaj, MinMin} = version_tuple(ShouldAbort, MinOtpVsn, + {MinMaj, MinMin, MinPatch} = version_tuple(ShouldAbort, MinOtpVsn, "configured"), - {OtpMaj, OtpMin} = version_tuple(ShouldAbort, + {OtpMaj, OtpMin, OtpPatch} = version_tuple(ShouldAbort, erlang:system_info(otp_release), "OTP Release"), - case {OtpMaj, OtpMin} >= {MinMaj, MinMin} of + case {OtpMaj, OtpMin, OtpPatch} >= {MinMaj, MinMin, MinPatch} of true -> ?DEBUG("~s satisfies the requirement for vsn ~s~n", [erlang:system_info(otp_release), @@ -122,12 +123,17 @@ check_versions(Config) -> end end. +version_tuple(OtpRelease) -> + version_tuple(keep_going, OtpRelease, ""). + version_tuple(ShouldAbort, OtpRelease, Type) -> - case re:run(OtpRelease, "R?(\\d+)B?-?(\\d+)?", [{capture, all, list}]) of + case re:run(OtpRelease, "R?(\\d+)B?\.?(\\d+)?\.?-?(\\d+)?", [{capture, all, list}]) of + {match, [_Full, Maj, Min, Patch]} -> + {list_to_integer(Maj), list_to_integer(Min), list_to_integer(Patch)}; {match, [_Full, Maj, Min]} -> - {list_to_integer(Maj), list_to_integer(Min)}; + {list_to_integer(Maj), list_to_integer(Min), 0}; {match, [_Full, Maj]} -> - {list_to_integer(Maj), 0}; + {list_to_integer(Maj), 0, 0}; nomatch -> maybe_abort(ShouldAbort, "Cannot parse ~s version string: ~s~n", |