소스 검색

Merge pull request #2389 from ferd/autoupdate-hex-plugin-pkg-on-upgrade

Run pkg updates on plugin upgrades
pull/2390/head
Fred Hebert 4 년 전
committed by GitHub
부모
커밋
125e307636
No known key found for this signature in database GPG 키 ID: 4AEE18F83AFDEB23
2개의 변경된 파일28개의 추가작업 그리고 6개의 파일을 삭제
  1. +1
    -6
      src/rebar_pkg_resource.erl
  2. +27
    -0
      src/rebar_prv_plugins_upgrade.erl

+ 1
- 6
src/rebar_pkg_resource.erl 파일 보기

@ -60,12 +60,7 @@ lock(AppInfo, _) ->
Res :: boolean().
needs_update(AppInfo, _) ->
{pkg, _Name, Vsn, _OldHash, _Hash, _} = rebar_app_info:source(AppInfo),
case rebar_utils:to_binary(rebar_app_info:original_vsn(AppInfo)) =:= rebar_utils:to_binary(Vsn) of
true ->
false;
false ->
true
end.
rebar_utils:to_binary(rebar_app_info:original_vsn(AppInfo)) =/= rebar_utils:to_binary(Vsn).
%%------------------------------------------------------------------------------
%% @doc

+ 27
- 0
src/rebar_prv_plugins_upgrade.erl 파일 보기

@ -62,6 +62,7 @@ upgrade(Plugin, State) ->
?PRV_ERROR({not_found, Plugin});
{ok, P, Profile} ->
State1 = rebar_state:set(State, deps_dir, ?DEFAULT_PLUGINS_DIR),
maybe_update_pkg(P, State1),
{Apps, State2} = rebar_prv_install_deps:handle_deps_as_profile(Profile, State1, [P], true),
{no_cycle, Sorted} = rebar_prv_install_deps:find_cycles(Apps),
@ -92,3 +93,29 @@ find_plugin(Plugin, Profiles, State) ->
build_plugin(ToBuild, State) ->
Providers = rebar_state:providers(State),
rebar_prv_compile:compile(State, Providers, ToBuild, plugins).
maybe_update_pkg(Name, State) ->
try rebar_app_utils:parse_dep(root, ?DEFAULT_PLUGINS_DIR, Name, State, [], 0) of
AppInfo ->
Source = rebar_app_info:source(AppInfo),
case element(1, Source) of
pkg ->
Resources = rebar_state:resources(State),
#{repos := RepoConfigs} = rebar_resource_v2:find_resource_state(pkg, Resources),
PkgName = element(2, Source),
[update_package(PkgName, RepoConfig, State) || RepoConfig <- RepoConfigs];
_ ->
skip
end
catch
throw:?PRV_ERROR({parse_dep, _}) ->
skip
end.
update_package(Name, RepoConfig, State) ->
case rebar_packages:update_package(Name, RepoConfig, State) of
fail ->
?WARN("Failed to fetch updates for package ~ts from repo ~ts", [Name, maps:get(name, RepoConfig)]);
_ ->
ok
end.

불러오는 중...
취소
저장