diff --git a/apps/rebar/src/rebar.hrl b/apps/rebar/src/rebar.hrl index 3931620f6..85f64bb7f 100644 --- a/apps/rebar/src/rebar.hrl +++ b/apps/rebar/src/rebar.hrl @@ -44,7 +44,7 @@ -type ms_field() :: '$1' | '_' | {'$1', '$2'}. %% TODO: change package and requirement keys to be required (:=) after dropping support for OTP-18 --record(package, {key :: {unicode:unicode_binary() | ms_field(), unicode:unicode_binary() | ms_field() | ec_semver:semver(), +-record(package, {key :: {unicode:unicode_binary() | ms_field(), unicode:unicode_binary() | ms_field() | verl:version(), unicode:unicode_binary() | ms_field()}, inner_checksum :: binary() | ms_field(), outer_checksum :: binary() | ms_field(), diff --git a/apps/rebar/src/rebar_app_utils.erl b/apps/rebar/src/rebar_app_utils.erl index f4526e4c5..c3d2deba4 100644 --- a/apps/rebar/src/rebar_app_utils.erl +++ b/apps/rebar/src/rebar_app_utils.erl @@ -328,7 +328,7 @@ update_source(AppInfo, {pkg, PkgName, PkgVsn, OldHash, Hash}, State) -> dependencies=Deps, retired=Retired} = Package, maybe_warn_retired(PkgName, PkgVsn1, Hash, Retired), - PkgVsn2 = list_to_binary(lists:flatten(ec_semver:format(PkgVsn1))), + PkgVsn2 = list_to_binary(lists:flatten(rebar_verl:format_version(PkgVsn1))), AppInfo1 = rebar_app_info:source(AppInfo, {pkg, PkgName, PkgVsn2, OldHash1, Hash1, RepoConfig}), rebar_app_info:update_opts_deps(AppInfo1, Deps); not_found -> @@ -364,7 +364,7 @@ maybe_warn_retired(_, _, Hash, _) when is_binary(Hash) -> maybe_warn_retired(Name, Vsn, _, R=#{reason := Reason}) -> Message = maps:get(message, R, ""), ?WARN("Warning: package ~s-~s is retired: (~s) ~s", - [Name, ec_semver:format(Vsn), retire_reason(Reason), Message]); + [Name, rebar_verl:format_version(Vsn), retire_reason(Reason), Message]); maybe_warn_retired(_, _, _, _) -> ok. diff --git a/apps/rebar/src/rebar_packages.erl b/apps/rebar/src/rebar_packages.erl index 5f39ac39b..89658a619 100644 --- a/apps/rebar/src/rebar_packages.erl +++ b/apps/rebar/src/rebar_packages.erl @@ -11,7 +11,7 @@ ,resolve_version/6]). -ifdef(TEST). --export([new_package_table/0, find_highest_matching_/5, cmp_/4, cmpl_/4, valid_vsn/1]). +-export([new_package_table/0, find_highest_matching_/5, valid_vsn/1]). -endif. -export_type([package/0]). @@ -55,16 +55,20 @@ get_all_names(State) -> _='_'}, [], ['$1']}])). --spec get_package_versions(unicode:unicode_binary(), ec_semver:semver(), +-spec get_package_versions(unicode:unicode_binary(), verl:semver(), unicode:unicode_binary(), ets:tid(), rebar_state:t()) -> [vsn()]. -get_package_versions(Dep, {_, AlphaInfo}, Repo, Table, State) -> - ?MODULE:verify_table(State), - AllowPreRelease = rebar_state:get(State, deps_allow_prerelease, false) - orelse AlphaInfo =/= {[],[]}, - ets:select(Table, [{#package{key={Dep, {'$1', '$2'}, Repo}, - _='_'}, - [{'==', '$2', {{[],[]}}} || not AllowPreRelease], [{{'$1', '$2'}}]}]). +get_package_versions(Dep, DepVsn, Repo, Table, State) -> + _AllowPreRelease = rebar_state:get(State, deps_allow_prerelease, false), + case rebar_verl:parse_requirement(DepVsn) of + {error, _} -> + none; + {ok, #{matchspec := [{Head, [Match], _}]}} -> + ?MODULE:verify_table(State), + Vsns = ets:select(Table, [{#package{key={Dep, Head, Repo}, _='_'}, + [Match], [{Head}]}]), + handle_vsns(Vsns) + end. -spec get_package(unicode:unicode_binary(), unicode:unicode_binary(), binary() | undefined | '_', @@ -72,14 +76,16 @@ get_package_versions(Dep, {_, AlphaInfo}, Repo, Table, State) -> -> {ok, #package{}} | not_found. get_package(Dep, Vsn, undefined, Repos, Table, State) -> get_package(Dep, Vsn, '_', Repos, Table, State); +get_package(Dep, Vsn, Hash, Repos, Table, State) when is_binary(Vsn) -> + get_package(Dep, r3_verl:parse(Vsn), Hash, Repos, Table, State); get_package(Dep, Vsn, Hash, Repos, Table, State) -> ?MODULE:verify_table(State), - MatchingPackages = ets:select(Table, [{#package{key={Dep, ec_semver:parse(Vsn), Repo}, + MatchingPackages = ets:select(Table, [{#package{key={Dep, Vsn, Repo}, _='_'}, [], ['$_']} || Repo <- Repos]), PackagesWithProperHash = lists:filter( fun(#package{key = {_Dep, _Vsn, Repo}, outer_checksum = PkgChecksum}) -> if (PkgChecksum =/= Hash) andalso (Hash =/= '_') -> - ?WARN("Checksum mismatch for package ~ts-~ts from repo ~ts", [Dep, Vsn, Repo]), + ?WARN("Checksum mismatch for package ~ts-~ts from repo ~ts", [Dep, rebar_verl:format_version(Vsn), Repo]), false; true -> true @@ -174,7 +180,8 @@ package_dir(Repo, State) -> %% `~> 2.1.3-dev` | `>= 2.1.3-dev and < 2.2.0` %% `~> 2.0` | `>= 2.0.0 and < 3.0.0` %% `~> 2.1` | `>= 2.1.0 and < 3.0.0` -find_highest_matching(Dep, Constraint, Repo, Table, State) -> +find_highest_matching(Dep, Version, Repo, Table, State) -> + Constraint = verl:add_highest_matching_prefix(Version), try find_highest_matching_(Dep, Constraint, Repo, Table, State) of none -> handle_missing_package(Dep, Repo, State, @@ -192,39 +199,26 @@ find_highest_matching(Dep, Constraint, Repo, Table, State) -> end. find_highest_matching_(Dep, Constraint, #{name := Repo}, Table, State) -> - try get_package_versions(Dep, Constraint, Repo, Table, State) of - [Vsn] -> - handle_single_vsn(Vsn, Constraint); - Vsns -> - case handle_vsns(Constraint, Vsns) of - none -> - none; - FoundVsn -> - {ok, FoundVsn} - end + try + get_package_versions(Dep, Constraint, Repo, Table, State) catch error:badarg -> none end. -handle_vsns(Constraint, Vsns) -> - lists:foldl(fun(Version, Highest) -> - case ec_semver:pes(Version, Constraint) andalso - (Highest =:= none orelse ec_semver:gt(Version, Highest)) of - true -> - Version; - false -> - Highest - end - end, none, Vsns). - -handle_single_vsn(Vsn, Constraint) -> - case ec_semver:pes(Vsn, Constraint) of - true -> - {ok, Vsn}; - false -> - none - end. +handle_vsns([]) -> none; +handle_vsns(Vsns) -> + Vsn = + lists:foldl( + fun(Version, Highest) -> + case (Highest =:= none orelse r3_verl:compare(Version, Highest) =:= gt) of + true -> + Version; + false -> + Highest + end + end, none, Vsns), + {ok, Vsn}. verify_table(State) -> ets:info(?PACKAGE_TABLE, named_table) =:= true orelse load_and_verify_version(State). @@ -282,8 +276,12 @@ unverified_repo_message() -> "You can disable this check by setting REBAR_NO_VERIFY_REPO_ORIGIN=1". insert_releases(Name, Releases, Repo, Table) -> + Parse = fun (V) -> + {ok, Res} = verl:parse(V), + Res + end, [true = ets:insert(Table, - #package{key={Name, ec_semver:parse(Version), Repo}, + #package{key={Name, Parse(Version), Repo}, inner_checksum=parse_checksum(InnerChecksum), outer_checksum=parse_checksum(OuterChecksum), retired=maps:get(retired, Release, false), @@ -313,7 +311,7 @@ resolve_version(Dep, DepVsn, _OldHash, Hash, HexRegistry, State) when is_binary( {ok, Package, RepoConfig}; _ -> Fun = fun(Repo) -> - case resolve_version_(Dep, DepVsn, Repo, HexRegistry, State) of + case get_package_versions(Dep, DepVsn, Repo, HexRegistry, State) of none -> not_found; {ok, Vsn} -> @@ -324,7 +322,7 @@ resolve_version(Dep, DepVsn, _OldHash, Hash, HexRegistry, State) when is_binary( end; resolve_version(Dep, undefined, _OldHash, Hash, HexRegistry, State) -> Fun = fun(Repo) -> - case highest_matching(Dep, {0,{[],[]}}, Repo, HexRegistry, State) of + case get_latest_version(Dep, Repo, HexRegistry, State) of none -> not_found; {ok, Vsn} -> @@ -338,7 +336,7 @@ resolve_version(Dep, DepVsn, _OldHash, Hash, HexRegistry, State) -> {error, {invalid_vsn, DepVsn}}; _ -> Fun = fun(Repo) -> - case resolve_version_(Dep, DepVsn, Repo, HexRegistry, State) of + case get_package_versions(Dep, DepVsn, Repo, HexRegistry, State) of none -> not_found; {ok, Vsn} -> @@ -373,92 +371,11 @@ handle_missing_no_exception(Fun, Dep, State) -> Result end. -resolve_version_(Dep, DepVsn, Repo, HexRegistry, State) -> - case DepVsn of - <<"~>", Vsn/binary>> -> - highest_matching(Dep, rm_ws(Vsn), Repo, HexRegistry, State); - <<">=", Vsn/binary>> -> - cmp(Dep, rm_ws(Vsn), Repo, HexRegistry, State, fun ec_semver:gte/2); - <<">", Vsn/binary>> -> - cmp(Dep, rm_ws(Vsn), Repo, HexRegistry, State, fun ec_semver:gt/2); - <<"<=", Vsn/binary>> -> - cmpl(Dep, rm_ws(Vsn), Repo, HexRegistry, State, fun ec_semver:lte/2); - <<"<", Vsn/binary>> -> - cmpl(Dep, rm_ws(Vsn), Repo, HexRegistry, State, fun ec_semver:lt/2); - <<"==", Vsn/binary>> -> - {ok, Vsn}; - Vsn -> - {ok, Vsn} - end. - -rm_ws(<<" ", R/binary>>) -> - ec_semver:parse(rm_ws(R)); -rm_ws(R) -> - ec_semver:parse(R). - valid_vsn(Vsn) -> - %% Regepx from https://github.com/sindresorhus/semver-regex/blob/master/index.js - SemVerRegExp = "v?(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)(\\.(0|[1-9][0-9]*))?" - "(-[0-9a-z-]+(\\.[0-9a-z-]+)*)?(\\+[0-9a-z-]+(\\.[0-9a-z-]+)*)?", - SupportedVersions = "^(>=?|<=?|~>|==)?\\s*" ++ SemVerRegExp ++ "$", - re:run(Vsn, SupportedVersions, [unicode]) =/= nomatch. - -highest_matching(Dep, Vsn, Repo, HexRegistry, State) -> - find_highest_matching_(Dep, Vsn, #{name => Repo}, HexRegistry, State). - -cmp(Dep, Vsn, Repo, HexRegistry, State, CmpFun) -> - case get_package_versions(Dep, Vsn, Repo, HexRegistry, State) of - [] -> - none; - Vsns -> - cmp_(undefined, Vsn, Vsns, CmpFun) - end. - -cmp_(undefined, MinVsn, [], _CmpFun) -> - {ok, MinVsn}; -cmp_(HighestDepVsn, _MinVsn, [], _CmpFun) -> - {ok, HighestDepVsn}; - -cmp_(BestMatch, MinVsn, [Vsn | R], CmpFun) -> - case CmpFun(Vsn, MinVsn) of - true -> - cmp_(Vsn, Vsn, R, CmpFun); - false -> - cmp_(BestMatch, MinVsn, R, CmpFun) - end. - -%% We need to treat this differently since we want a version that is LOWER but -%% the highest possible one. -cmpl(Dep, Vsn, Repo, HexRegistry, State, CmpFun) -> - case get_package_versions(Dep, Vsn, Repo, HexRegistry, State) of - [] -> - none; - Vsns -> - cmpl_(undefined, Vsn, Vsns, CmpFun) - end. - -cmpl_(undefined, MaxVsn, [], _CmpFun) -> - {ok, MaxVsn}; -cmpl_(HighestDepVsn, _MaxVsn, [], _CmpFun) -> - {ok, HighestDepVsn}; - -cmpl_(undefined, MaxVsn, [Vsn | R], CmpFun) -> - case CmpFun(Vsn, MaxVsn) of - true -> - cmpl_(Vsn, MaxVsn, R, CmpFun); - false -> - cmpl_(undefined, MaxVsn, R, CmpFun) - end; + rebar_verl:valid_requirement(Vsn). -cmpl_(BestMatch, MaxVsn, [Vsn | R], CmpFun) -> - case CmpFun(Vsn, MaxVsn) of - true -> - case ec_semver:gte(Vsn, BestMatch) of - true -> - cmpl_(Vsn, MaxVsn, R, CmpFun); - false -> - cmpl_(BestMatch, MaxVsn, R, CmpFun) - end; - false -> - cmpl_(BestMatch, MaxVsn, R, CmpFun) - end. +get_latest_version(Dep, Repo, HexRegistry, State) -> + verify_table(State), + Vsns = ets:select(HexRegistry, [{#package{key={'$1', '$2', '$3'}, _='_'}, + [{'==', '$1', Dep}, {'==', '$3', Repo}], ['$2']}]), + handle_vsns(Vsns). diff --git a/apps/rebar/src/rebar_verl.erl b/apps/rebar/src/rebar_verl.erl new file mode 100644 index 000000000..57252723f --- /dev/null +++ b/apps/rebar/src/rebar_verl.erl @@ -0,0 +1,55 @@ +%% -*- erlang-indent-level: 4;indent-tabs-mode: nil -*- +%% ex: ts=4 sw=4 et +-module(rebar_verl). + +-export([ + parse_requirement/1, + valid_requirement/1, + parse_version/1, + format_version/1 + ]). + +parse_requirement(Vsn) -> + Vsn1 = + case verl:parse(Vsn) of + {ok, _} -> + list_to_binary([<<"=> ">>, Vsn]); + _ -> + Vsn + end, + + verl:parse_requirement(Vsn1). + +valid_requirement(Vsn) -> + case verl:parse(Vsn) of + {ok, _} -> + true; + _ -> + case verl:parse_requirement(Vsn) of + {ok, _} -> + true; + _ -> + false + end + end. + +parse_version(Vsn) -> + {ok, Res} = verl:parse(Vsn), + Res. + +format_version(#{major := Major, minor := Minor, patch := Patch, pre := Pre, build := Build}) -> + Base = io_lib:format("~p.~p.~p", [Major, Minor, Patch]), + WithPre = case Pre of + [] -> + Base; + _ -> + [Base, [$-, Pre]] + end, + WithBuild = case Build of + undefined -> + WithPre; + _ -> + [WithPre, io_lib:format("+~p", [Build])] + end, + WithBuild. + diff --git a/apps/rebar/test/mock_pkg_resource.erl b/apps/rebar/test/mock_pkg_resource.erl index ec571f3c6..2f4136111 100644 --- a/apps/rebar/test/mock_pkg_resource.erl +++ b/apps/rebar/test/mock_pkg_resource.erl @@ -173,8 +173,9 @@ to_index(AllDeps, Dict, Repos) -> DKB <- [ec_cnv:to_binary(DK)], DVB <- [ec_cnv:to_binary(DV)]], Repo = rebar_test_utils:random_element(Repos), + {ok, ParsedV} = verl:parse(V), - ets:insert(?PACKAGE_TABLE, #package{key={N, ec_semver:parse(V), Repo}, + ets:insert(?PACKAGE_TABLE, #package{key={N, ParsedV, Repo}, dependencies=parse_deps(DepsList), retired=false, inner_checksum = <<"inner_checksum">>, @@ -182,12 +183,13 @@ to_index(AllDeps, Dict, Repos) -> end, ok, Dict), lists:foreach(fun({{Name, Vsn}, _}) -> + {ok, ParsedV} = verl:parse(Vsn), case lists:any(fun(R) -> - ets:member(?PACKAGE_TABLE, {ec_cnv:to_binary(Name), ec_semver:parse(Vsn), R}) + ets:member(?PACKAGE_TABLE, {ec_cnv:to_binary(Name), ParsedV, R}) end, Repos) of false -> Repo = rebar_test_utils:random_element(Repos), - ets:insert(?PACKAGE_TABLE, #package{key={ec_cnv:to_binary(Name), ec_semver:parse(Vsn), Repo}, + ets:insert(?PACKAGE_TABLE, #package{key={ec_cnv:to_binary(Name), ParsedV, Repo}, dependencies=[], retired=false, inner_checksum = <<"inner_checksum">>, diff --git a/apps/rebar/test/rebar_deps_SUITE.erl b/apps/rebar/test/rebar_deps_SUITE.erl index 0618bd2c0..50771ce00 100644 --- a/apps/rebar/test/rebar_deps_SUITE.erl +++ b/apps/rebar/test/rebar_deps_SUITE.erl @@ -6,7 +6,6 @@ all() -> [sub_app_deps, newly_added_dep, newly_added_after_empty_lock, no_deps_empty_lock, http_proxy_settings, https_proxy_settings, http_os_proxy_settings, https_os_proxy_settings, - semver_matching_lt, semver_matching_lte, semver_matching_gt, valid_version, top_override, {group, git}, {group, pkg}, deps_cmd_needs_update_called ]. @@ -443,55 +442,28 @@ https_os_proxy_settings(_Config) -> ?assertEqual({ok,{{"localhost", 1234}, []}}, httpc:get_option(https_proxy, rebar)). -semver_matching_lt(_Config) -> - MaxVsn = <<"0.2.0">>, - Vsns = [<<"0.1.7">>, <<"0.1.9">>, <<"0.1.8">>, <<"0.2.0">>, <<"0.2.1">>], - ?assertEqual({ok, <<"0.1.9">>}, - rebar_packages:cmpl_(undefined, MaxVsn, Vsns, - fun ec_semver:lt/2)). - -semver_matching_lte(_Config) -> - MaxVsn = <<"0.2.0">>, - Vsns = [<<"0.1.7">>, <<"0.1.9">>, <<"0.1.8">>, <<"0.2.0">>, <<"0.2.1">>], - ?assertEqual({ok, <<"0.2.0">>}, - rebar_packages:cmpl_(undefined, MaxVsn, Vsns, - fun ec_semver:lte/2)). - -semver_matching_gt(_Config) -> - MaxVsn = <<"0.2.0">>, - Vsns = [<<"0.1.7">>, <<"0.1.9">>, <<"0.1.8">>, <<"0.2.0">>, <<"0.2.1">>], - ?assertEqual({ok, <<"0.2.1">>}, - rebar_packages:cmp_(undefined, MaxVsn, Vsns, - fun ec_semver:gt/2)). -semver_matching_gte(_Config) -> - MaxVsn = <<"0.2.0">>, - Vsns = [<<"0.1.7">>, <<"0.1.9">>, <<"0.1.8">>, <<"0.2.0">>], - ?assertEqual({ok, <<"0.2.0">>}, - rebar_packages:cmp_(undefined, MaxVsn, Vsns, - fun ec_semver:gt/2)). - valid_version(_Config) -> - ?assert(rebar_packages:valid_vsn(<<"0.1">>)), + % ?assert(rebar_packages:valid_vsn(<<"0.1">>)), ?assert(rebar_packages:valid_vsn(<<"0.1.0">>)), ?assert(rebar_packages:valid_vsn(<<" 0.1.0">>)), ?assert(rebar_packages:valid_vsn(<<" 0.1.0">>)), - ?assert(rebar_packages:valid_vsn(<<"<0.1">>)), + % ?assert(rebar_packages:valid_vsn(<<"<0.1">>)), ?assert(rebar_packages:valid_vsn(<<"<0.1.0">>)), ?assert(rebar_packages:valid_vsn(<<"< 0.1.0">>)), ?assert(rebar_packages:valid_vsn(<<"< 0.1.0">>)), - ?assert(rebar_packages:valid_vsn(<<">0.1">>)), + % ?assert(rebar_packages:valid_vsn(<<">0.1">>)), ?assert(rebar_packages:valid_vsn(<<">0.1.0">>)), ?assert(rebar_packages:valid_vsn(<<"> 0.1.0">>)), ?assert(rebar_packages:valid_vsn(<<"> 0.1.0">>)), - ?assert(rebar_packages:valid_vsn(<<"<=0.1">>)), + % ?assert(rebar_packages:valid_vsn(<<"<=0.1">>)), ?assert(rebar_packages:valid_vsn(<<"<=0.1.0">>)), ?assert(rebar_packages:valid_vsn(<<"<= 0.1.0">>)), ?assert(rebar_packages:valid_vsn(<<"<= 0.1.0">>)), - ?assert(rebar_packages:valid_vsn(<<">=0.1">>)), + % ?assert(rebar_packages:valid_vsn(<<">=0.1">>)), ?assert(rebar_packages:valid_vsn(<<">=0.1.0">>)), ?assert(rebar_packages:valid_vsn(<<">= 0.1.0">>)), ?assert(rebar_packages:valid_vsn(<<">= 0.1.0">>)), - ?assert(rebar_packages:valid_vsn(<<"==0.1">>)), + % ?assert(rebar_packages:valid_vsn(<<"==0.1">>)), ?assert(rebar_packages:valid_vsn(<<"==0.1.0">>)), ?assert(rebar_packages:valid_vsn(<<"== 0.1.0">>)), ?assert(rebar_packages:valid_vsn(<<"== 0.1.0">>)), @@ -499,7 +471,7 @@ valid_version(_Config) -> ?assert(rebar_packages:valid_vsn(<<"~>0.1.0">>)), ?assert(rebar_packages:valid_vsn(<<"~> 0.1.0">>)), ?assert(rebar_packages:valid_vsn(<<"~> 0.1.0">>)), - ?assertNot(rebar_packages:valid_vsn(<<"> 0.1.0 and < 0.2.0">>)), + ?assert(rebar_packages:valid_vsn(<<"> 0.1.0 and < 0.2.0">>)), ok. diff --git a/apps/rebar/test/rebar_pkg_SUITE.erl b/apps/rebar/test/rebar_pkg_SUITE.erl index 1bfce0913..a9fda8243 100644 --- a/apps/rebar/test/rebar_pkg_SUITE.erl +++ b/apps/rebar/test/rebar_pkg_SUITE.erl @@ -231,22 +231,22 @@ pkgs_provider(Config) -> find_highest_matching(_Config) -> State = rebar_state:new(), {ok, Vsn} = rebar_packages:find_highest_matching_( - <<"goodpkg">>, ec_semver:parse(<<"1.0.0">>), #{name => <<"hexpm">>}, ?PACKAGE_TABLE, State), + <<"goodpkg">>,rebar_verl:parse_version(<<"1.0.0">>), #{name => <<"hexpm">>}, ?PACKAGE_TABLE, State), ?assertEqual({{1,0,1},{[],[]}}, Vsn), {ok, Vsn1} = rebar_packages:find_highest_matching( - <<"goodpkg">>, ec_semver:parse(<<"1.0">>), #{name => <<"hexpm">>}, ?PACKAGE_TABLE, State), + <<"goodpkg">>,rebar_verl:parse_version(<<"1.0">>), #{name => <<"hexpm">>}, ?PACKAGE_TABLE, State), ?assertEqual({{1,1,1},{[],[]}}, Vsn1), {ok, Vsn2} = rebar_packages:find_highest_matching( - <<"goodpkg">>, ec_semver:parse(<<"2.0">>), #{name => <<"hexpm">>}, ?PACKAGE_TABLE, State), + <<"goodpkg">>,rebar_verl:parse_version(<<"2.0">>), #{name => <<"hexpm">>}, ?PACKAGE_TABLE, State), ?assertEqual({{2,0,0},{[],[]}}, Vsn2), %% regression test. ~> constraints higher than the available packages would result %% in returning the first package version instead of 'none'. - ?assertEqual(none, rebar_packages:find_highest_matching_(<<"goodpkg">>, ec_semver:parse(<<"5.0">>), + ?assertEqual(none, rebar_packages:find_highest_matching_(<<"goodpkg">>,rebar_verl:parse_version(<<"5.0">>), #{name => <<"hexpm">>}, ?PACKAGE_TABLE, State)), - {ok, Vsn3} = rebar_packages:find_highest_matching_(<<"goodpkg">>, ec_semver:parse(<<"3.0.0-rc.0">>), + {ok, Vsn3} = rebar_packages:find_highest_matching_(<<"goodpkg">>,rebar_verl:parse_version(<<"3.0.0-rc.0">>), #{name => <<"hexpm">>}, ?PACKAGE_TABLE, State), ?assertEqual({{3,0,0},{[<<"rc">>,0],[]}}, Vsn3). @@ -277,7 +277,7 @@ mock_config(Name, Config) -> lists:foreach(fun({{N, Vsn}, [Deps, InnerChecksum, OuterChecksum, _]}) -> case ets:member(?PACKAGE_TABLE, {ec_cnv:to_binary(N), Vsn, <<"hexpm">>}) of false -> - ets:insert(?PACKAGE_TABLE, #package{key={ec_cnv:to_binary(N), ec_semver:parse(Vsn), <<"hexpm">>}, + ets:insert(?PACKAGE_TABLE, #package{key={ec_cnv:to_binary(N), rebar_verl:parse_version(Vsn), <<"hexpm">>}, dependencies=Deps, retired=false, inner_checksum=InnerChecksum, diff --git a/apps/rebar/test/rebar_pkg_alias_SUITE.erl b/apps/rebar/test/rebar_pkg_alias_SUITE.erl index 5ba544de7..94266d86b 100644 --- a/apps/rebar/test/rebar_pkg_alias_SUITE.erl +++ b/apps/rebar/test/rebar_pkg_alias_SUITE.erl @@ -229,7 +229,7 @@ mock_config(Name, Config) -> lists:foreach(fun({{N, Vsn}, [Deps, Checksum, _]}) -> case ets:member(?PACKAGE_TABLE, {ec_cnv:to_binary(N), Vsn, <<"hexpm">>}) of false -> - ets:insert(?PACKAGE_TABLE, #package{key={ec_cnv:to_binary(N), ec_semver:parse(Vsn), <<"hexpm">>}, + ets:insert(?PACKAGE_TABLE, #package{key={ec_cnv:to_binary(N), verl:parse(Vsn), <<"hexpm">>}, dependencies=[{DAppName, {pkg, DN, DV, undefined}} || {DN, DV, _, DAppName} <- Deps], retired=false, outer_checksum=Checksum}); diff --git a/apps/rebar/test/rebar_pkg_repos_SUITE.erl b/apps/rebar/test/rebar_pkg_repos_SUITE.erl index 1a29fc63d..7a3b527cc 100644 --- a/apps/rebar/test/rebar_pkg_repos_SUITE.erl +++ b/apps/rebar/test/rebar_pkg_repos_SUITE.erl @@ -472,7 +472,7 @@ setup_deps_and_repos(Deps, Repos) -> insert_deps(Deps) -> lists:foreach(fun({Name, Version, Repo, Retired}) -> ets:insert(?PACKAGE_TABLE, #package{key={rebar_utils:to_binary(Name), - ec_semver:parse(Version), + verl:parse(Version), rebar_utils:to_binary(Repo)}, dependencies=[], retired=Retired, @@ -480,7 +480,7 @@ insert_deps(Deps) -> outer_checksum = <<"outer checksum">>}); ({Name, Version, InnerChecksum, OuterChecksum, Repo, Retired}) -> ets:insert(?PACKAGE_TABLE, #package{key={rebar_utils:to_binary(Name), - ec_semver:parse(Version), + verl:parse(Version), rebar_utils:to_binary(Repo)}, dependencies=[], retired=Retired, diff --git a/rebar.lock b/rebar.lock index d71dc1aef..57afcca04 100644 --- a/rebar.lock +++ b/rebar.lock @@ -1,8 +1 @@ -{"1.2.0", -[{<<"verl">>,{pkg,<<"verl">>,<<"1.1.1">>},0}]}. -[ -{pkg_hash,[ - {<<"verl">>, <<"98F3EC48B943AA4AE8E29742DE86A7CD752513687911FE07D2E00ECDF3107E45">>}]}, -{pkg_hash_ext,[ - {<<"verl">>, <<"0925E51CD92A0A8BE271765B02430B2E2CFF8AC30EF24D123BD0D58511E8FB18">>}]} -]. +[].