Skip to content

Commit aecbdcd

Browse files
committed
Add rebar_state:all_checkouts_deps/1 and apply suggestions
1 parent c9fa733 commit aecbdcd

File tree

4 files changed

+12
-5
lines changed

4 files changed

+12
-5
lines changed

src/rebar_prv_lock.erl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ do(State) ->
3838
rebar_config:maybe_write_lock_file(filename:join(Dir, ?LOCK_FILE), Locks, OldLocks),
3939
State1 = rebar_state:set(State, {locks, default}, Locks),
4040

41-
Checkouts = [rebar_app_info:name(Dep)
42-
|| Dep <- rebar_state:all_deps(State), rebar_app_info:is_checkout(Dep)],
41+
Checkouts = [rebar_app_info:name(Dep) || Dep <- rebar_state:all_checkout_deps(State)],
4342
%% Remove the checkout dependencies from the old lock info
4443
%% so that they do not appear in the rebar_utils:info_useless/1 warning.
4544
OldLockNames = [element(1,L) || L <- OldLocks] -- Checkouts,

src/rebar_prv_upgrade.erl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,7 @@ do_(State) ->
8686
DepsDict = deps_dict(rebar_state:all_deps(State)),
8787
AltDeps = find_non_default_deps(Deps, State),
8888
FilteredNames = cull_default_names_if_profiles(Names, Deps, State),
89-
Checkouts = [rebar_app_info:name(Dep)
90-
|| Dep <- rebar_state:all_deps(State), rebar_app_info:is_checkout(Dep)],
89+
Checkouts = [rebar_app_info:name(Dep) || Dep <- rebar_state:all_checkout_deps(State)],
9190
case prepare_locks(FilteredNames, Deps, Locks, [], DepsDict, AltDeps, Checkouts) of
9291
{error, Reason} ->
9392
{error, Reason};
@@ -126,7 +125,8 @@ format_error({transitive_dependency, Name}) ->
126125
"Promote it to your top-level rebar.config file to upgrade it.",
127126
[Name]);
128127
format_error({checkout_dependency, Name}) ->
129-
io_lib:format("Dependency ~ts is a checkout dependency and cannot be upgraded.", [Name]);
128+
io_lib:format("Dependency ~ts is a checkout dependency under _checkouts/ and checkouts cannot be upgraded.",
129+
[Name]);
130130
format_error(Reason) ->
131131
io_lib:format("~p", [Reason]).
132132

src/rebar_state.erl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
deps_to_build/1, deps_to_build/2,
3333
all_plugin_deps/1, all_plugin_deps/2, update_all_plugin_deps/2,
3434
all_deps/1, all_deps/2, update_all_deps/2, merge_all_deps/2,
35+
all_checkout_deps/1,
3536
namespace/1, namespace/2,
3637

3738
deps_names/1,
@@ -342,6 +343,9 @@ all_deps(#state_t{all_deps=Apps}) ->
342343
all_deps(State=#state_t{}, NewApps) ->
343344
State#state_t{all_deps=NewApps}.
344345

346+
all_checkout_deps(#state_t{all_deps=Apps}) ->
347+
[App || App <- Apps, rebar_app_info:is_checkout(App)].
348+
345349
all_plugin_deps(#state_t{all_plugin_deps=Apps}) ->
346350
Apps.
347351

test/rebar_compile_SUITE.erl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,10 @@ paths_checkout_deps(Config) ->
461461

462462
{ok, State} = rebar_test_utils:run_and_check(Config, RebarConfig, ["compile"], return),
463463

464+
[AppName2] = rebar_state:all_checkout_deps(State),
465+
Name2Bin = binary:list_to_bin(Name2),
466+
Name2Bin = rebar_app_info:name(AppName2),
467+
464468
code:add_paths(rebar_state:code_paths(State, all_deps)),
465469
ok = application:load(list_to_atom(Name2)),
466470
Loaded = application:loaded_applications(),

0 commit comments

Comments
 (0)