summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Sloughter <t@crashfast.com>2015-11-17 14:16:58 -0600
committerTristan Sloughter <t@crashfast.com>2015-11-17 14:17:20 -0600
commitd4e876500772657a5a6339905d82424c81d73d2a (patch)
treea0fc0acf5813453d9730de511d163eb83c8d9ac0
parent25914c35086beca01aaf879c5227adba7dfe1037 (diff)
only add package list of versions to registry if it has the right buildtool support
-rw-r--r--src/rebar_prv_update.erl16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/rebar_prv_update.erl b/src/rebar_prv_update.erl
index 6637ebe..33d757a 100644
--- a/src/rebar_prv_update.erl
+++ b/src/rebar_prv_update.erl
@@ -92,12 +92,24 @@ hex_to_index(State) ->
false ->
true
end;
- ({Pkg, [Vsns]}, _) when is_binary(Pkg) ->
- ets:insert(?PACKAGE_TABLE, {Pkg, Vsns});
(_, _) ->
true
end, true, Registry),
+ ets:foldl(fun({Pkg, [[]]}, _) when is_binary(Pkg) ->
+ true;
+ ({Pkg, [Vsns=[Vsn | _Rest]]}, _) when is_binary(Pkg) ->
+ %% Verify the package is of the right build tool by checking if the first
+ %% version exists in the table from the foldl above
+ case ets:member(?PACKAGE_TABLE, {Pkg, Vsn}) of
+ true ->
+ ets:insert(?PACKAGE_TABLE, {Pkg, Vsns});
+ false ->
+ true
+ end;
+ (_, _) ->
+ true
+ end, true, Registry),
ets:insert(?PACKAGE_TABLE, {package_index_version, ?PACKAGE_INDEX_VERSION}),
?INFO("Writing index to ~s", [PackageIndex]),
ets:tab2file(?PACKAGE_TABLE, PackageIndex),