Sfoglia il codice sorgente

fixes for dialyzer findings

pull/31/head
Tristan Sloughter 10 anni fa
parent
commit
5673fe035d
8 ha cambiato i file con 43 aggiunte e 63 eliminazioni
  1. +1
    -1
      src/rebar_core.erl
  2. +24
    -19
      src/rebar_fetch.erl
  3. +1
    -6
      src/rebar_git_resource.erl
  4. +1
    -0
      src/rebar_plugins.erl
  5. +7
    -8
      src/rebar_prv_install_deps.erl
  6. +7
    -3
      src/rebar_prv_upgrade.erl
  7. +1
    -1
      src/rebar_resource.erl
  8. +1
    -25
      src/rebar_utils.erl

+ 1
- 1
src/rebar_core.erl Vedi File

@ -57,7 +57,7 @@ process_command(State, Command) ->
end
end.
-spec do([atom()], rebar_state:t()) -> {ok, rebar_state:t()} | {error, string()}.
-spec do([{atom(), atom()}], rebar_state:t()) -> {ok, rebar_state:t()} | {error, string()}.
do([], State) ->
{ok, State};
do([{ProviderName, Profile} | Rest], State) ->

+ 24
- 19
src/rebar_fetch.erl Vedi File

@ -24,25 +24,30 @@ lock_source(AppDir, Source) ->
-spec download_source(file:filename_all(), rebar_resource:resource()) -> true | {error, any()}.
download_source(AppDir, Source) ->
Module = get_resource_type(Source),
TmpDir = ec_file:insecure_mkdtemp(),
AppDir1 = ec_cnv:to_list(AppDir),
ec_file:mkdir_p(AppDir1),
case Module:download(TmpDir, Source) of
{ok, _} ->
code:del_path(filename:absname(filename:join(AppDir1, "ebin"))),
ec_file:remove(filename:absname(AppDir1), [recursive]),
ok = ec_file:copy(TmpDir, filename:absname(AppDir1), [recursive]),
true;
{tarball, File} ->
ok = erl_tar:extract(File, [{cwd, TmpDir}
,compressed]),
BaseName = filename:basename(AppDir1),
[FromDir] = filelib:wildcard(filename:join(TmpDir, BaseName++"-*")),
code:del_path(filename:absname(filename:join(AppDir1, "ebin"))),
ec_file:remove(filename:absname(AppDir1), [recursive]),
ok = ec_file:copy(FromDir, filename:absname(AppDir1), [recursive]),
true
try
Module = get_resource_type(Source),
TmpDir = ec_file:insecure_mkdtemp(),
AppDir1 = ec_cnv:to_list(AppDir),
ec_file:mkdir_p(AppDir1),
case Module:download(TmpDir, Source) of
{ok, _} ->
code:del_path(filename:absname(filename:join(AppDir1, "ebin"))),
ec_file:remove(filename:absname(AppDir1), [recursive]),
ok = ec_file:copy(TmpDir, filename:absname(AppDir1), [recursive]),
true;
{tarball, File} ->
ok = erl_tar:extract(File, [{cwd, TmpDir}
,compressed]),
BaseName = filename:basename(AppDir1),
[FromDir] = filelib:wildcard(filename:join(TmpDir, BaseName++"-*")),
code:del_path(filename:absname(filename:join(AppDir1, "ebin"))),
ec_file:remove(filename:absname(AppDir1), [recursive]),
ok = ec_file:copy(FromDir, filename:absname(AppDir1), [recursive]),
true
end
catch
_:E ->
{error, E}
end.
-spec needs_update(file:filename_all(), rebar_resource:resource()) -> boolean() | {error, string()}.

+ 1
- 6
src/rebar_git_resource.erl Vedi File

@ -126,12 +126,7 @@ collect_default_refcount() ->
build_vsn_string(Vsn, RawRef, RawCount) ->
%% Cleanup the tag and the Ref information. Basically leading 'v's and
%% whitespace needs to go away.
RefTag = case RawRef of
undefined ->
"";
RawRef ->
[".ref", re:replace(RawRef, "\\s", "", [global])]
end,
RefTag = [".ref", re:replace(RawRef, "\\s", "", [global])],
Count = erlang:iolist_to_binary(re:replace(RawCount, "\\s", "", [global])),
%% Create the valid [semver](http://semver.org) version from the tag

+ 1
- 0
src/rebar_plugins.erl Vedi File

@ -25,6 +25,7 @@ install(State) ->
State2 = rebar_state:set(State1, deps_dir, OldDepsDir),
{ok, PluginProviders, State2}.
-spec handle_plugin(rebar_prv_install_deps:dep(), rebar_state:t()) -> {true, any()} | false.
handle_plugin(Plugin, State) ->
try
{ok, _, State1} = rebar_prv_install_deps:handle_deps(State, [Plugin]),

+ 7
- 8
src/rebar_prv_install_deps.erl Vedi File

@ -37,6 +37,8 @@
-export([handle_deps/2,
handle_deps/3]).
-export_type([dep/0]).
-define(PROVIDER, install_deps).
-define(DEPS, [app_discovery]).
@ -91,12 +93,12 @@ do(State) ->
format_error(Reason) ->
io_lib:format("~p", [Reason]).
-spec handle_deps(rebar_state:t(), [dep()]) ->
-spec handle_deps(rebar_state:t(), list()) ->
{ok, [rebar_app_info:t()], rebar_state:t()} | {error, string()}.
handle_deps(State, Deps) ->
handle_deps(State, Deps, false).
-spec handle_deps(rebar_state:t(), [dep()], boolean() | {true, binary(), integer()})
-spec handle_deps(rebar_state:t(), list(), boolean() | {true, binary(), integer()})
-> {ok, [rebar_app_info:t()], rebar_state:t()} | {error, string()}.
handle_deps(State, [], _) ->
{ok, [], State};
@ -121,9 +123,7 @@ handle_deps(State, Deps, Update) ->
{ok, []} ->
throw({rebar_digraph, no_solution});
{ok, Solution} ->
Solution;
[] ->
throw({rebar_digraph, no_solution})
Solution
end,
update_pkg_deps(S, Packages, Update, Seen, State1)
@ -182,8 +182,7 @@ package_to_app(DepsDir, Packages, {Name, Vsn}) ->
rebar_app_info:source(AppInfo2, {pkg, Name, Vsn, Link})
end.
-spec update_src_deps(integer(), list(), list(), list(), rebar_state:t(), boolean(), sets:set(binary())) ->
{rebar_state:t(), [binary()]}.
-spec update_src_deps(non_neg_integer(), list(), list(), list(), rebar_state:t(), boolean(), sets:set(binary())) -> {rebar_state:t(), list(), list(), sets:set(binary())}.
update_src_deps(Level, SrcDeps, PkgDeps, SrcApps, State, Update, Seen) ->
case lists:foldl(fun(AppInfo, {SrcDepsAcc, PkgDepsAcc, SrcAppsAcc, StateAcc, SeenAcc}) ->
%% If not seen, add to list of locks to write out
@ -323,7 +322,7 @@ maybe_fetch(State, AppInfo, Update, Seen) ->
end
end.
-spec parse_deps(rebar_state:t(), binary(), [dep()]) -> {[rebar_app_info:t()], [pkg_dep()]}.
-spec parse_deps(rebar_state:t(), binary(), list()) -> {[rebar_app_info:t()], [pkg_dep()]}.
parse_deps(State, DepsDir, Deps) ->
lists:foldl(fun({Name, Vsn}, {SrcDepsAcc, PkgDepsAcc}) ->
{SrcDepsAcc, [parse_goal(ec_cnv:to_binary(Name)

+ 7
- 3
src/rebar_prv_upgrade.erl Vedi File

@ -42,9 +42,13 @@ do(State) ->
case lists:keyfind(Name, 1, Locks) of
{_, _, _, Level} ->
Deps = rebar_state:get(State, deps),
Dep = lists:keyfind(binary_to_atom(Name, utf8), 1, Deps),
rebar_prv_install_deps:handle_deps(State, [Dep], {true, Name, Level}),
{ok, State};
case lists:keyfind(binary_to_atom(Name, utf8), 1, Deps) of
false ->
{error, io_lib:format("No such dependency ~s~n", [Name])};
Dep ->
rebar_prv_install_deps:handle_deps(State, [Dep], {true, Name, Level}),
{ok, State}
end;
_ ->
{error, io_lib:format("No such dependency ~s~n", [Name])}
end.

+ 1
- 1
src/rebar_resource.erl Vedi File

@ -36,7 +36,7 @@ behaviour_info(_) ->
-callback download(file:filename_all(), tuple()) ->
{tarball, file:filename_all()} | {ok, any()} | {error, any()}.
-callback needs_update(file:filename_all(), tuple()) ->
{tarball, file:filename_all()} | {ok, any()} | {error, any()}.
boolean().
-callback make_vsn(file:filename_all()) ->
{plain, string()} | {error, string()}.

+ 1
- 25
src/rebar_utils.erl Vedi File

@ -528,31 +528,7 @@ vcs_vsn_1(Vcs, Dir) ->
unknown ->
?ABORT("vcs_vsn: Unknown vsn format: ~p\n", [Vcs]);
{error, Reason} ->
?ABORT("vcs_vsn: ~s\n", [Reason]);
Cmd ->
%% If there is a valid VCS directory in the application directory,
%% use that version info
Extension = lists:concat([".", Vcs]),
case filelib:is_dir(filename:join(Dir, Extension)) of
true ->
?DEBUG("vcs_vsn: Primary vcs used for ~s\n", [Dir]),
vcs_vsn_invoke(Cmd, Dir);
false ->
%% No VCS directory found for the app. Depending on source
%% tree structure, there may be one higher up, but that can
%% yield unexpected results when used with deps. So, we
%% fallback to searching for a priv/vsn.Vcs file.
VsnFile = filename:join([Dir, "priv", "vsn" ++ Extension]),
case file:read_file(VsnFile) of
{ok, VsnBin} ->
?DEBUG("vcs_vsn: Read ~s from priv/vsn.~p\n",
[VsnBin, Vcs]),
string:strip(binary_to_list(VsnBin), right, $\n);
{error, enoent} ->
?DEBUG("vcs_vsn: Fallback to vcs for ~s\n", [Dir]),
vcs_vsn_invoke(Cmd, Dir)
end
end
?ABORT("vcs_vsn: ~s\n", [Reason])
end.
%% Temp work around for repos like relx that use "semver"

Caricamento…
Annulla
Salva