diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/rebar_prv_install_deps.erl | 3 | ||||
-rw-r--r-- | src/rebar_prv_plugins_upgrade.erl | 17 | ||||
-rw-r--r-- | src/rebar_prv_upgrade.erl | 13 | ||||
-rw-r--r-- | src/rebar_utils.erl | 15 |
4 files changed, 20 insertions, 28 deletions
diff --git a/src/rebar_prv_install_deps.erl b/src/rebar_prv_install_deps.erl index 69956f0..c4fd985 100644 --- a/src/rebar_prv_install_deps.erl +++ b/src/rebar_prv_install_deps.erl @@ -524,9 +524,6 @@ parse_dep(Name, {SrcDepsAcc, PkgDepsAcc}, DepsDir, IsLock, State) when is_atom(N parse_dep({Name, Source}, {SrcDepsAcc, PkgDepsAcc}, DepsDir, IsLock, State) when is_tuple(Source) -> Dep = new_dep(DepsDir, Name, [], Source, IsLock, State), {[Dep | SrcDepsAcc], PkgDepsAcc}; -parse_dep({Name, Source}, {SrcDepsAcc, PkgDepsAcc}, DepsDir, IsLock, State) when is_tuple(Source) -> - Dep = new_dep(DepsDir, Name, [], Source, IsLock, State), - {[Dep | SrcDepsAcc], PkgDepsAcc}; parse_dep({Name, _Vsn, Source}, {SrcDepsAcc, PkgDepsAcc}, DepsDir, IsLock, State) when is_tuple(Source) -> Dep = new_dep(DepsDir, Name, [], Source, IsLock, State), {[Dep | SrcDepsAcc], PkgDepsAcc}; diff --git a/src/rebar_prv_plugins_upgrade.erl b/src/rebar_prv_plugins_upgrade.erl index f67b7dc..dfc9990 100644 --- a/src/rebar_prv_plugins_upgrade.erl +++ b/src/rebar_prv_plugins_upgrade.erl @@ -79,7 +79,7 @@ upgrade(Plugin, State) -> find_plugin(Plugin, Profiles, State) -> ec_lists:search(fun(Profile) -> Plugins = rebar_state:get(State, {plugins, Profile}, []), - case find(list_to_atom(Plugin), Plugins) of + case rebar_utils:tup_find(list_to_atom(Plugin), Plugins) of false -> not_found; P -> @@ -87,21 +87,6 @@ find_plugin(Plugin, Profiles, State) -> end end, Profiles). -find(_Plugin, []) -> - false; -find(Plugin, [Plugin | _Plugins]) -> - Plugin; -find(Plugin, [Plugin1 | Plugins]) when is_tuple(Plugin1) -> - case element(1, Plugin1) =:= Plugin of - true -> - Plugin1; - false -> - find(Plugin, Plugins) - end; -find(Plugin, [_Plugin | Plugins]) -> - find(Plugin, Plugins). - - build_plugin(AppInfo, Apps, State) -> Providers = rebar_state:providers(State), AppDir = rebar_app_info:dir(AppInfo), diff --git a/src/rebar_prv_upgrade.erl b/src/rebar_prv_upgrade.erl index 49d5674..46aed9e 100644 --- a/src/rebar_prv_upgrade.erl +++ b/src/rebar_prv_upgrade.erl @@ -94,21 +94,16 @@ prepare_locks([Name|Names], Deps, Locks, Unlocks) -> AtomName = binary_to_atom(Name, utf8), case lists:keyfind(Name, 1, Locks) of {_, _, 0} = Lock -> - case {lists:keyfind(AtomName, 1, Deps), lists:member(AtomName, Deps)} of - {false, false} -> + case rebar_utils:tup_find(AtomName, Deps) of + false -> ?PRV_ERROR({unknown_dependency, Name}); - {Dep, false} -> - {Source, NewLocks, NewUnlocks} = prepare_lock(Dep, Lock, Locks), - prepare_locks(Names, Deps, NewLocks, - [{Name, Source, 0} | NewUnlocks ++ Unlocks]); - {false, true} -> % package as a single atom - Dep = AtomName, + Dep -> {Source, NewLocks, NewUnlocks} = prepare_lock(Dep, Lock, Locks), prepare_locks(Names, Deps, NewLocks, [{Name, Source, 0} | NewUnlocks ++ Unlocks]) end; {_, _, Level} = Lock when Level > 0 -> - case lists:keyfind(AtomName, 1, Deps) of + case rebar_utils:tup_find(AtomName, Deps) of false -> ?PRV_ERROR({transitive_dependency, Name}); Dep -> % Dep has been promoted diff --git a/src/rebar_utils.erl b/src/rebar_utils.erl index bcb4777..c729b58 100644 --- a/src/rebar_utils.erl +++ b/src/rebar_utils.erl @@ -56,6 +56,7 @@ wordsize/0, tup_umerge/2, tup_sort/1, + tup_find/2, line_count/1, set_httpc_options/0, escape_chars/1, @@ -266,6 +267,20 @@ tup_umerge([], Olds) -> tup_umerge([New|News], Olds) -> lists:reverse(umerge(News, Olds, [], New)). +tup_find(_Elem, []) -> + false; +tup_find(Elem, [Elem | _Elems]) -> + Elem; +tup_find(Elem, [Elem1 | Elems]) when is_tuple(Elem1) -> + case element(1, Elem1) =:= Elem of + true -> + Elem1; + false -> + tup_find(Elem, Elems) + end; +tup_find(Elem, [_Elem | Elems]) -> + tup_find(Elem, Elems). + %% This is equivalent to umerge2_2 in the stdlib, except we use the expanded %% value/key only to compare umerge(News, [Old|Olds], Merged, Cmp) when element(1, Cmp) == element(1, Old); |