Browse Source

Add rebar_state:all_checkouts_deps/1 and apply suggestions

pull/2335/head
Pablo Costas 4 years ago
parent
commit
aecbdcdd44
4 changed files with 12 additions and 5 deletions
  1. +1
    -2
      src/rebar_prv_lock.erl
  2. +3
    -3
      src/rebar_prv_upgrade.erl
  3. +4
    -0
      src/rebar_state.erl
  4. +4
    -0
      test/rebar_compile_SUITE.erl

+ 1
- 2
src/rebar_prv_lock.erl View File

@ -38,8 +38,7 @@ do(State) ->
rebar_config:maybe_write_lock_file(filename:join(Dir, ?LOCK_FILE), Locks, OldLocks), rebar_config:maybe_write_lock_file(filename:join(Dir, ?LOCK_FILE), Locks, OldLocks),
State1 = rebar_state:set(State, {locks, default}, Locks), State1 = rebar_state:set(State, {locks, default}, Locks),
Checkouts = [rebar_app_info:name(Dep)
|| Dep <- rebar_state:all_deps(State), rebar_app_info:is_checkout(Dep)],
Checkouts = [rebar_app_info:name(Dep) || Dep <- rebar_state:all_checkout_deps(State)],
%% Remove the checkout dependencies from the old lock info %% Remove the checkout dependencies from the old lock info
%% so that they do not appear in the rebar_utils:info_useless/1 warning. %% so that they do not appear in the rebar_utils:info_useless/1 warning.
OldLockNames = [element(1,L) || L <- OldLocks] -- Checkouts, OldLockNames = [element(1,L) || L <- OldLocks] -- Checkouts,

+ 3
- 3
src/rebar_prv_upgrade.erl View File

@ -86,8 +86,7 @@ do_(State) ->
DepsDict = deps_dict(rebar_state:all_deps(State)), DepsDict = deps_dict(rebar_state:all_deps(State)),
AltDeps = find_non_default_deps(Deps, State), AltDeps = find_non_default_deps(Deps, State),
FilteredNames = cull_default_names_if_profiles(Names, Deps, State), FilteredNames = cull_default_names_if_profiles(Names, Deps, State),
Checkouts = [rebar_app_info:name(Dep)
|| Dep <- rebar_state:all_deps(State), rebar_app_info:is_checkout(Dep)],
Checkouts = [rebar_app_info:name(Dep) || Dep <- rebar_state:all_checkout_deps(State)],
case prepare_locks(FilteredNames, Deps, Locks, [], DepsDict, AltDeps, Checkouts) of case prepare_locks(FilteredNames, Deps, Locks, [], DepsDict, AltDeps, Checkouts) of
{error, Reason} -> {error, Reason} ->
{error, Reason}; {error, Reason};
@ -126,7 +125,8 @@ format_error({transitive_dependency, Name}) ->
"Promote it to your top-level rebar.config file to upgrade it.", "Promote it to your top-level rebar.config file to upgrade it.",
[Name]); [Name]);
format_error({checkout_dependency, Name}) -> format_error({checkout_dependency, Name}) ->
io_lib:format("Dependency ~ts is a checkout dependency and cannot be upgraded.", [Name]);
io_lib:format("Dependency ~ts is a checkout dependency under _checkouts/ and checkouts cannot be upgraded.",
[Name]);
format_error(Reason) -> format_error(Reason) ->
io_lib:format("~p", [Reason]). io_lib:format("~p", [Reason]).

+ 4
- 0
src/rebar_state.erl View File

@ -32,6 +32,7 @@
deps_to_build/1, deps_to_build/2, deps_to_build/1, deps_to_build/2,
all_plugin_deps/1, all_plugin_deps/2, update_all_plugin_deps/2, all_plugin_deps/1, all_plugin_deps/2, update_all_plugin_deps/2,
all_deps/1, all_deps/2, update_all_deps/2, merge_all_deps/2, all_deps/1, all_deps/2, update_all_deps/2, merge_all_deps/2,
all_checkout_deps/1,
namespace/1, namespace/2, namespace/1, namespace/2,
deps_names/1, deps_names/1,
@ -342,6 +343,9 @@ all_deps(#state_t{all_deps=Apps}) ->
all_deps(State=#state_t{}, NewApps) -> all_deps(State=#state_t{}, NewApps) ->
State#state_t{all_deps=NewApps}. State#state_t{all_deps=NewApps}.
all_checkout_deps(#state_t{all_deps=Apps}) ->
[App || App <- Apps, rebar_app_info:is_checkout(App)].
all_plugin_deps(#state_t{all_plugin_deps=Apps}) -> all_plugin_deps(#state_t{all_plugin_deps=Apps}) ->
Apps. Apps.

+ 4
- 0
test/rebar_compile_SUITE.erl View File

@ -461,6 +461,10 @@ paths_checkout_deps(Config) ->
{ok, State} = rebar_test_utils:run_and_check(Config, RebarConfig, ["compile"], return), {ok, State} = rebar_test_utils:run_and_check(Config, RebarConfig, ["compile"], return),
[AppName2] = rebar_state:all_checkout_deps(State),
Name2Bin = binary:list_to_bin(Name2),
Name2Bin = rebar_app_info:name(AppName2),
code:add_paths(rebar_state:code_paths(State, all_deps)), code:add_paths(rebar_state:code_paths(State, all_deps)),
ok = application:load(list_to_atom(Name2)), ok = application:load(list_to_atom(Name2)),
Loaded = application:loaded_applications(), Loaded = application:loaded_applications(),

Loading…
Cancel
Save