瀏覽代碼

handle missing package in registry by skipping

pull/387/head
Tristan Sloughter 10 年之前
父節點
當前提交
ce74589a56
共有 4 個檔案被更改,包括 18 行新增14 行删除
  1. +1
    -5
      rebar.lock
  2. +7
    -4
      src/rebar_packages.erl
  3. +1
    -1
      src/rebar_prv_install_deps.erl
  4. +9
    -4
      src/rebar_prv_update.erl

+ 1
- 5
rebar.lock 查看文件

@ -1,8 +1,4 @@
[{<<"relx">>,
{git,"https://github.com/tsloughter/relx.git",
{ref,"6e0d048d3840464539deddd9d5b53e9f421edee4"}},
0},
{<<"providers">>,
[{<<"providers">>,
{git,"https://github.com/tsloughter/providers.git", {git,"https://github.com/tsloughter/providers.git",
{ref,"7563ba7e916d5a35972b25b3aa1945ffe0a8e7a5"}}, {ref,"7563ba7e916d5a35972b25b3aa1945ffe0a8e7a5"}},
0}, 0},

+ 7
- 4
src/rebar_packages.erl 查看文件

@ -73,14 +73,14 @@ find_highest_matching(Dep, Constraint, T) ->
[{Dep, [[Vsn]]}] -> [{Dep, [[Vsn]]}] ->
case ec_semver:pes(Vsn, Constraint) of case ec_semver:pes(Vsn, Constraint) of
true -> true ->
Vsn;
{ok, Vsn};
false -> false ->
?WARN("Only existing version of ~s is ~s which does not match constraint ~~> ~s. " ?WARN("Only existing version of ~s is ~s which does not match constraint ~~> ~s. "
"Using anyway, but it is not guarenteed to work.", [Dep, Vsn, Constraint]), "Using anyway, but it is not guarenteed to work.", [Dep, Vsn, Constraint]),
Vsn
{ok, Vsn}
end; end;
[{Dep, [[HeadVsn | VsnTail]]}] -> [{Dep, [[HeadVsn | VsnTail]]}] ->
lists:foldl(fun(Version, Highest) ->
{ok, lists:foldl(fun(Version, Highest) ->
case ec_semver:pes(Version, Constraint) andalso case ec_semver:pes(Version, Constraint) andalso
ec_semver:gt(Version, Highest) of ec_semver:gt(Version, Highest) of
true -> true ->
@ -88,5 +88,8 @@ find_highest_matching(Dep, Constraint, T) ->
false -> false ->
Highest Highest
end end
end, HeadVsn, VsnTail)
end, HeadVsn, VsnTail)};
[] ->
?WARN("Missing registry entry for package ~s", [Dep]),
none
end. end.

+ 1
- 1
src/rebar_prv_install_deps.erl 查看文件

@ -626,7 +626,7 @@ not_needs_compile(App) ->
get_package(Dep, State) -> get_package(Dep, State) ->
case rebar_state:registry(State) of case rebar_state:registry(State) of
{ok, T} -> {ok, T} ->
HighestDepVsn = rebar_packages:find_highest_matching(Dep, "0", T),
{ok, HighestDepVsn} = rebar_packages:find_highest_matching(Dep, "0", T),
{Dep, HighestDepVsn}; {Dep, HighestDepVsn};
error -> error ->
throw(?PRV_ERROR({load_registry_fail, Dep})) throw(?PRV_ERROR({load_registry_fail, Dep}))

+ 9
- 4
src/rebar_prv_update.erl 查看文件

@ -52,7 +52,8 @@ do(State) ->
write_registry(Dict, Graph, State), write_registry(Dict, Graph, State),
ok ok
catch catch
_E:_C ->
_E:C ->
?DEBUG("Error creating package index: ~p ~p", [C, erlang:get_stacktrace()]),
throw(?PRV_ERROR(package_index_write)) throw(?PRV_ERROR(package_index_write))
end, end,
@ -94,9 +95,13 @@ update_graph(Pkg, PkgVsn, Deps, HexRegistry, Graph) ->
lists:foldl(fun([Dep, DepVsn, false, _AppName | _], DepsListAcc) -> lists:foldl(fun([Dep, DepVsn, false, _AppName | _], DepsListAcc) ->
case DepVsn of case DepVsn of
<<"~> ", Vsn/binary>> -> <<"~> ", Vsn/binary>> ->
HighestDepVsn = rebar_packages:find_highest_matching(Dep, Vsn, HexRegistry),
digraph:add_edge(Graph, {Pkg, PkgVsn}, {Dep, HighestDepVsn}),
[{Dep, DepVsn} | DepsListAcc];
case rebar_packages:find_highest_matching(Dep, Vsn, HexRegistry) of
{ok, HighestDepVsn} ->
digraph:add_edge(Graph, {Pkg, PkgVsn}, {Dep, HighestDepVsn}),
[{Dep, DepVsn} | DepsListAcc];
none ->
DepsListAcc
end;
Vsn -> Vsn ->
digraph:add_edge(Graph, {Pkg, PkgVsn}, {Dep, Vsn}), digraph:add_edge(Graph, {Pkg, PkgVsn}, {Dep, Vsn}),
[{Dep, Vsn} | DepsListAcc] [{Dep, Vsn} | DepsListAcc]

Loading…
取消
儲存