瀏覽代碼

add repo_name to repoconfig used with hex_core to be compatible (#1996)

pull/1999/head
Tristan Sloughter 6 年之前
committed by GitHub
父節點
當前提交
c934ccca29
沒有發現已知的金鑰在資料庫的簽署中 GPG 金鑰 ID: 4AEE18F83AFDEB23
共有 2 個檔案被更改,包括 9 行新增4 行删除
  1. +4
    -1
      src/rebar_hex_repos.erl
  2. +5
    -3
      test/rebar_pkg_repos_SUITE.erl

+ 4
- 1
src/rebar_hex_repos.erl 查看文件

@ -68,17 +68,20 @@ repos(HexConfig) ->
merge_repos(RepoList ++ [HexDefaultConfig]) merge_repos(RepoList ++ [HexDefaultConfig])
end. end.
%% merge repos must add a field repo_name to work with hex_core 0.4.0
-spec merge_repos([repo()]) -> [repo()]. -spec merge_repos([repo()]) -> [repo()].
merge_repos(Repos) -> merge_repos(Repos) ->
lists:foldl(fun(R=#{name := Name}, ReposAcc) -> lists:foldl(fun(R=#{name := Name}, ReposAcc) ->
%% private organizations include the parent repo before a : %% private organizations include the parent repo before a :
case rebar_string:split(Name, <<":">>) of case rebar_string:split(Name, <<":">>) of
[Repo, Org] -> [Repo, Org] ->
%% hex_core uses repo_name for parent
update_repo_list(R#{name => Name, update_repo_list(R#{name => Name,
repo_name => Repo,
organization => Org, organization => Org,
parent => Repo}, ReposAcc); parent => Repo}, ReposAcc);
_ -> _ ->
update_repo_list(R, ReposAcc)
update_repo_list(R#{repo_name => Name}, ReposAcc)
end end
end, [], Repos). end, [], Repos).

+ 5
- 3
test/rebar_pkg_repos_SUITE.erl 查看文件

@ -182,23 +182,25 @@ repo_merging(_Config) ->
repo_replacing(_Config) -> repo_replacing(_Config) ->
Repo1 = #{name => <<"repo-1">>, Repo1 = #{name => <<"repo-1">>,
repo_name => <<"repo-1">>,
api_url => <<"repo-1/api">>}, api_url => <<"repo-1/api">>},
Repo2 = #{name => <<"repo-2">>, Repo2 = #{name => <<"repo-2">>,
repo_name => <<"repo-2">>,
repo_url => <<"repo-2/repo">>, repo_url => <<"repo-2/repo">>,
repo_verify => false}, repo_verify => false},
?assertMatch([Repo1, Repo2, #{name := <<"hexpm">>}], ?assertMatch([Repo1, Repo2, #{name := <<"hexpm">>}],
rebar_hex_repos:repos([{repos, [Repo1]}, rebar_hex_repos:repos([{repos, [Repo1]},
{repos, [Repo2]}])),
{repos, [Repo2]}])),
%% use of replace is ignored if found in later entries than the first %% use of replace is ignored if found in later entries than the first
?assertMatch([Repo1, Repo2, #{name := <<"hexpm">>}], ?assertMatch([Repo1, Repo2, #{name := <<"hexpm">>}],
rebar_hex_repos:repos([{repos, [Repo1]}, rebar_hex_repos:repos([{repos, [Repo1]},
{repos, replace, [Repo2]}])),
{repos, replace, [Repo2]}])),
?assertMatch([Repo1], ?assertMatch([Repo1],
rebar_hex_repos:repos([{repos, replace, [Repo1]}, rebar_hex_repos:repos([{repos, replace, [Repo1]},
{repos, [Repo2]}])).
{repos, [Repo2]}])).
auth_merging(_Config) -> auth_merging(_Config) ->
Repo1 = #{name => <<"repo-1">>, Repo1 = #{name => <<"repo-1">>,

Loading…
取消
儲存