summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/rebar_prv_lock.erl9
-rw-r--r--src/rebar_prv_upgrade.erl24
-rw-r--r--src/rebar_utils.erl9
3 files changed, 26 insertions, 16 deletions
diff --git a/src/rebar_prv_lock.erl b/src/rebar_prv_lock.erl
index 058846a..1844934 100644
--- a/src/rebar_prv_lock.erl
+++ b/src/rebar_prv_lock.erl
@@ -29,11 +29,18 @@ init(State) ->
-spec do(rebar_state:t()) -> {ok, rebar_state:t()} | {error, string()}.
do(State) ->
+ OldLocks = rebar_state:get(State, {locks, default}, []),
Locks = build_locks(State),
Dir = rebar_state:dir(State),
file:write_file(filename:join(Dir, ?LOCK_FILE),
io_lib:format("~p.~n", [Locks])),
- {ok, State}.
+ State1 = rebar_state:set(State, {locks, default}, Locks),
+
+ OldLockNames = [element(1,L) || L <- OldLocks],
+ NewLockNames = [element(1,L) || L <- Locks],
+ rebar_utils:info_useless(OldLockNames, NewLockNames),
+
+ {ok, State1}.
-spec format_error(any()) -> iolist().
format_error(Reason) ->
diff --git a/src/rebar_prv_upgrade.erl b/src/rebar_prv_upgrade.erl
index a50e64f..3a371ca 100644
--- a/src/rebar_prv_upgrade.erl
+++ b/src/rebar_prv_upgrade.erl
@@ -13,7 +13,7 @@
-include_lib("providers/include/providers.hrl").
-define(PROVIDER, upgrade).
--define(DEPS, []).
+-define(DEPS, [lock]).
%% Also only upgrade top-level (0) deps. Transitive deps shouldn't be
%% upgradable -- if the user wants this, they should declare it at the
%% top level and then upgrade.
@@ -55,13 +55,15 @@ do(State) ->
State1 = rebar_state:set(State, {deps, default}, Deps0),
State2 = rebar_state:set(State1, {locks, default}, Locks0),
State3 = rebar_state:set(State2, upgrade, true),
- Res = rebar_prv_install_deps:do(State3),
+ UpdatedLocks = [L || L <- rebar_state:lock(State3),
+ lists:keymember(rebar_app_info:name(L), 1, Locks0)],
+ Res = rebar_prv_install_deps:do(rebar_state:lock(State3, UpdatedLocks)),
case Res of
{ok, State4} ->
- info_useless(
- [element(1,Lock) || Lock <- Locks],
- [rebar_app_info:name(App) || App <- rebar_state:lock(State4)]
- ),
+ rebar_utils:info_useless(
+ [element(1,Lock) || Lock <- Locks],
+ [rebar_app_info:name(App) || App <- rebar_state:lock(State4)]
+ ),
rebar_prv_lock:do(State4);
_ ->
Res
@@ -73,8 +75,8 @@ format_error({unknown_dependency, Name}) ->
io_lib:format("Dependency ~ts not found", [Name]);
format_error({transitive_dependency, Name}) ->
io_lib:format("Dependency ~ts is transient and cannot be safely upgraded. "
- "Promote it to your top-level rebar.config file to upgrade it.",
- [Name]);
+ "Promote it to your top-level rebar.config file to upgrade it.",
+ [Name]);
format_error(Reason) ->
io_lib:format("~p", [Reason]).
@@ -138,9 +140,3 @@ unlock_higher_than(Level, [App = {_,_,AppLevel} | Apps], Locks, Unlocks) ->
if AppLevel > Level -> unlock_higher_than(Level, Apps, Locks, [App | Unlocks]);
AppLevel =< Level -> unlock_higher_than(Level, Apps, [App | Locks], Unlocks)
end.
-
-info_useless(Old, New) ->
- [?INFO("App ~ts is no longer needed and can be deleted.", [Name])
- || Name <- Old,
- not lists:member(Name, New)],
- ok.
diff --git a/src/rebar_utils.erl b/src/rebar_utils.erl
index 7ae3d9c..30da523 100644
--- a/src/rebar_utils.erl
+++ b/src/rebar_utils.erl
@@ -63,7 +63,8 @@
escape_double_quotes/1,
escape_double_quotes_weak/1,
check_min_otp_version/1,
- check_blacklisted_otp_versions/1]).
+ check_blacklisted_otp_versions/1,
+ info_useless/2]).
%% for internal use only
-export([otp_release/0]).
@@ -766,3 +767,9 @@ escape_double_quotes(Str) ->
%% "escape inside these" but allow *
escape_double_quotes_weak(Str) ->
re:replace(Str, "([\"\\\\`!$&;])", "\\\\&", [global, {return, list}]).
+
+info_useless(Old, New) ->
+ [?INFO("App ~ts is no longer needed and can be deleted.", [Name])
+ || Name <- Old,
+ not lists:member(Name, New)],
+ ok.