Skip to content

Commit

Permalink
Merge pull request #2032 from fenollp/p-hex
Browse files Browse the repository at this point in the history
format hex packages in a nice/human way
  • Loading branch information
ferd authored May 6, 2019
2 parents ec224b7 + 1997057 commit 4b610f5
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 20 deletions.
15 changes: 6 additions & 9 deletions src/rebar_prv_install_deps.erl
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ update_seen_dep(AppInfo, _Profile, _Level, Deps, Apps, State, Upgrade, Seen, Loc
%% meaning there is no conflict, so don't warn about it.
skip;
_ ->
warn_skip_deps(Name, Source, State)
warn_skip_deps(AppInfo, State)
end;
true ->
ok
Expand Down Expand Up @@ -395,17 +395,15 @@ make_relative_to_root(State, Path) when is_list(Path) ->
rebar_dir:make_relative_path(Path, Root).

fetch_app(AppInfo, State) ->
?INFO("Fetching ~ts (~p)", [rebar_app_info:name(AppInfo),
rebar_resource_v2:format_source(rebar_app_info:source(AppInfo))]),
?INFO("Fetching ~ts", [rebar_resource_v2:format_source(AppInfo)]),
rebar_fetch:download_source(AppInfo, State).

maybe_upgrade(AppInfo, _AppDir, Upgrade, State) ->
case Upgrade orelse rebar_app_info:is_lock(AppInfo) of
true ->
case rebar_fetch:needs_update(AppInfo, State) of
true ->
?INFO("Upgrading ~ts (~p)", [rebar_app_info:name(AppInfo),
rebar_resource_v2:format_source(rebar_app_info:source(AppInfo))]),
?INFO("Upgrading ~ts", [rebar_resource_v2:format_source(AppInfo)]),
rebar_fetch:download_source(AppInfo, State);
false ->
case Upgrade of
Expand All @@ -420,11 +418,10 @@ maybe_upgrade(AppInfo, _AppDir, Upgrade, State) ->
AppInfo
end.

warn_skip_deps(Name, Source, State) ->
Msg = "Skipping ~ts (from ~p) as an app of the same name "
warn_skip_deps(AppInfo, State) ->
Msg = "Skipping ~ts as an app of the same name "
"has already been fetched",
Args = [Name,
rebar_resource_v2:format_source(Source)],
Args = [rebar_resource_v2:format_source(AppInfo)],
case rebar_state:get(State, deps_error_on_conflict, false) of
false ->
case rebar_state:get(State, deps_warning_on_conflict, true) of
Expand Down
12 changes: 9 additions & 3 deletions src/rebar_resource_v2.erl
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,20 @@ find_resource(Type, Resources) ->

find_resource_state(Type, Resources) ->
case lists:keyfind(Type, #resource.type, Resources) of
false ->
false ->
{error, not_found};
#resource{state=State} ->
State
end.

format_source({pkg, Name, Vsn, _Hash, _}) -> {pkg, Name, Vsn};
format_source(Source) -> Source.
format_source(AppInfo) ->
Name = rebar_app_info:name(AppInfo),
case rebar_app_info:source(AppInfo) of
{pkg, _Name, Vsn, _Hash, _} ->
io_lib:format("~ts v~s", [Name, Vsn]);
Source ->
io_lib:format("~ts (from ~p)", [Name, Source])
end.

lock(AppInfo, State) ->
resource_run(lock, rebar_app_info:source(AppInfo), [AppInfo], State).
Expand Down
11 changes: 7 additions & 4 deletions test/rebar_deps_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -560,10 +560,13 @@ check_warnings(Warns, [{Name, Vsn} | Rest], Type) ->

in_warnings(git, Warns, NameRaw, VsnRaw) ->
Name = iolist_to_binary(NameRaw),
1 =< length([1 || {_, [AppName, {git, _, {_, Vsn}}]} <- Warns,
AppName =:= Name, Vsn =:= VsnRaw]);
Vsn = iolist_to_binary([$",VsnRaw,$"]),
1 =< length([1 || {_, [[AppName, $\s,$(,$f,$r,$o,$m,$\s,[${,["git",$,, _URL, $,,[${,["tag",$,, AppVsn], $}]],$}],$)]]} <- Warns,
iolist_to_binary(AppName) =:= Name,
iolist_to_binary(AppVsn) =:= Vsn]);
in_warnings(pkg, Warns, NameRaw, VsnRaw) ->
Name = iolist_to_binary(NameRaw),
Vsn = iolist_to_binary(VsnRaw),
1 =< length([1 || {_, [AppName, {pkg, _, AppVsn}]} <- Warns,
AppName =:= Name, AppVsn =:= Vsn]).
1 =< length([1 || {_, [[AppName, $\s,$v, AppVsn]]} <- Warns,
iolist_to_binary(AppName) =:= Name,
iolist_to_binary(AppVsn) =:= Vsn]).
11 changes: 7 additions & 4 deletions test/rebar_install_deps_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -481,10 +481,13 @@ check_warnings(Warns, none, _Type) ->

in_warnings(git, Warns, NameRaw, VsnRaw) ->
Name = iolist_to_binary(NameRaw),
1 =< length([1 || {_, [AppName, {git, _, {_, Vsn}}]} <- Warns,
AppName =:= Name, Vsn =:= VsnRaw]);
Vsn = iolist_to_binary([$",VsnRaw,$"]),
1 =< length([1 || {_, [[AppName, $\s,$(,$f,$r,$o,$m,$\s,[${,["git",$,, _URL, $,,[${,["tag",$,, AppVsn], $}]],$}],$)]]} <- Warns,
iolist_to_binary(AppName) =:= Name,
iolist_to_binary(AppVsn) =:= Vsn]);
in_warnings(pkg, Warns, NameRaw, VsnRaw) ->
Name = iolist_to_binary(NameRaw),
Vsn = iolist_to_binary(VsnRaw),
1 =< length([1 || {_, [AppName, {pkg, _, AppVsn}]} <- Warns,
AppName =:= Name, AppVsn =:= Vsn]).
1 =< length([1 || {_, [[AppName, $\s,$v, AppVsn]]} <- Warns,
iolist_to_binary(AppName) =:= Name,
iolist_to_binary(AppVsn) =:= Vsn]).

0 comments on commit 4b610f5

Please sign in to comment.