summaryrefslogtreecommitdiff
path: root/src/rebar_packages.erl
diff options
context:
space:
mode:
Diffstat (limited to 'src/rebar_packages.erl')
-rw-r--r--src/rebar_packages.erl24
1 files changed, 20 insertions, 4 deletions
diff --git a/src/rebar_packages.erl b/src/rebar_packages.erl
index 8982573..4ab5f9f 100644
--- a/src/rebar_packages.erl
+++ b/src/rebar_packages.erl
@@ -2,6 +2,7 @@
-export([get_packages/1
,registry/1
+ ,check_registry/3
,find_highest_matching/3]).
-export_type([package/0]).
@@ -52,6 +53,18 @@ registry(State) ->
error
end.
+check_registry(Pkg, Vsn, State) ->
+ case rebar_state:registry(State) of
+ {ok, T} ->
+ case ets:lookup(T, Pkg) of
+ [{Pkg, [Vsns]}] ->
+ lists:member(Vsn, Vsns);
+ _ ->
+ false
+ end;
+ error ->
+ false
+ end.
%% Hex supports use of ~> to specify the version required for a dependency.
%% Since rebar3 requires exact versions to choose from we find the highest
@@ -73,14 +86,14 @@ find_highest_matching(Dep, Constraint, T) ->
[{Dep, [[Vsn]]}] ->
case ec_semver:pes(Vsn, Constraint) of
true ->
- Vsn;
+ {ok, Vsn};
false ->
?WARN("Only existing version of ~s is ~s which does not match constraint ~~> ~s. "
"Using anyway, but it is not guarenteed to work.", [Dep, Vsn, Constraint]),
- Vsn
+ {ok, Vsn}
end;
[{Dep, [[HeadVsn | VsnTail]]}] ->
- lists:foldl(fun(Version, Highest) ->
+ {ok, lists:foldl(fun(Version, Highest) ->
case ec_semver:pes(Version, Constraint) andalso
ec_semver:gt(Version, Highest) of
true ->
@@ -88,5 +101,8 @@ find_highest_matching(Dep, Constraint, T) ->
false ->
Highest
end
- end, HeadVsn, VsnTail)
+ end, HeadVsn, VsnTail)};
+ [] ->
+ ?WARN("Missing registry entry for package ~s", [Dep]),
+ none
end.