Ver código fonte

fix upgrade of newly added pkg dep from scm locked dep

pull/650/head
Tristan Sloughter 10 anos atrás
pai
commit
e64671686f
3 arquivos alterados com 20 adições e 25 exclusões
  1. +1
    -16
      src/rebar_prv_plugins_upgrade.erl
  2. +4
    -9
      src/rebar_prv_upgrade.erl
  3. +15
    -0
      src/rebar_utils.erl

+ 1
- 16
src/rebar_prv_plugins_upgrade.erl Ver arquivo

@ -79,7 +79,7 @@ upgrade(Plugin, State) ->
find_plugin(Plugin, Profiles, State) -> find_plugin(Plugin, Profiles, State) ->
ec_lists:search(fun(Profile) -> ec_lists:search(fun(Profile) ->
Plugins = rebar_state:get(State, {plugins, 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 -> false ->
not_found; not_found;
P -> P ->
@ -87,21 +87,6 @@ find_plugin(Plugin, Profiles, State) ->
end end
end, Profiles). 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) -> build_plugin(AppInfo, Apps, State) ->
Providers = rebar_state:providers(State), Providers = rebar_state:providers(State),
AppDir = rebar_app_info:dir(AppInfo), AppDir = rebar_app_info:dir(AppInfo),

+ 4
- 9
src/rebar_prv_upgrade.erl Ver arquivo

@ -94,21 +94,16 @@ prepare_locks([Name|Names], Deps, Locks, Unlocks) ->
AtomName = binary_to_atom(Name, utf8), AtomName = binary_to_atom(Name, utf8),
case lists:keyfind(Name, 1, Locks) of case lists:keyfind(Name, 1, Locks) of
{_, _, 0} = Lock -> {_, _, 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}); ?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), {Source, NewLocks, NewUnlocks} = prepare_lock(Dep, Lock, Locks),
prepare_locks(Names, Deps, NewLocks, prepare_locks(Names, Deps, NewLocks,
[{Name, Source, 0} | NewUnlocks ++ Unlocks]) [{Name, Source, 0} | NewUnlocks ++ Unlocks])
end; end;
{_, _, Level} = Lock when Level > 0 -> {_, _, Level} = Lock when Level > 0 ->
case lists:keyfind(AtomName, 1, Deps) of
case rebar_utils:tup_find(AtomName, Deps) of
false -> false ->
?PRV_ERROR({transitive_dependency, Name}); ?PRV_ERROR({transitive_dependency, Name});
Dep -> % Dep has been promoted Dep -> % Dep has been promoted

+ 15
- 0
src/rebar_utils.erl Ver arquivo

@ -56,6 +56,7 @@
wordsize/0, wordsize/0,
tup_umerge/2, tup_umerge/2,
tup_sort/1, tup_sort/1,
tup_find/2,
line_count/1, line_count/1,
set_httpc_options/0, set_httpc_options/0,
escape_chars/1, escape_chars/1,
@ -264,6 +265,20 @@ tup_umerge([], Olds) ->
tup_umerge([New|News], Olds) -> tup_umerge([New|News], Olds) ->
lists:reverse(umerge(News, Olds, [], New)). 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 %% This is equivalent to umerge2_2 in the stdlib, except we use the expanded
%% value/key only to compare %% value/key only to compare
umerge(News, [Old|Olds], Merged, Cmp) when element(1, Cmp) == element(1, Old); umerge(News, [Old|Olds], Merged, Cmp) when element(1, Cmp) == element(1, Old);

Carregando…
Cancelar
Salvar