瀏覽代碼

Merge pull request #2412 from paulo-ferraz-oliveira/fix/dialyzer_warnings_over_otp_23

Prevent dialyzer warnings on OTP 23
pull/2431/head
Fred Hebert 4 年之前
committed by GitHub
父節點
當前提交
8adc139818
沒有發現已知的金鑰在資料庫的簽署中 GPG 金鑰 ID: 4AEE18F83AFDEB23
共有 42 個檔案被更改,包括 1106 行新增412 行删除
  1. +2
    -2
      .gitignore
  2. +2
    -2
      rebar.config
  3. +3
    -3
      src/rebar.hrl
  4. +1
    -1
      src/rebar_api.erl
  5. +15
    -14
      src/rebar_app_info.erl
  6. +3
    -1
      src/rebar_app_utils.erl
  7. +5
    -5
      src/rebar_compiler.erl
  8. +3
    -0
      src/rebar_compiler_dag.erl
  9. +1
    -1
      src/rebar_file_utils.erl
  10. +2
    -2
      src/rebar_git_resource.erl
  11. +4
    -2
      src/rebar_packages.erl
  12. +2
    -6
      src/rebar_paths.erl
  13. +6
    -6
      src/rebar_pkg_resource.erl
  14. +3
    -1
      src/rebar_prv_alias.erl
  15. +1
    -1
      src/rebar_prv_plugins_upgrade.erl
  16. +2
    -1
      src/rebar_resource_v2.erl
  17. +1
    -0
      src/rebar_state.erl
  18. +4
    -3
      src/rebar_uri.erl
  19. +3
    -3
      src/rebar_utils.erl
  20. +1
    -1
      src/vendored/r3_hex_api.erl
  21. +1
    -1
      src/vendored/r3_hex_api_key.erl
  22. +1
    -1
      src/vendored/r3_hex_api_package.erl
  23. +1
    -1
      src/vendored/r3_hex_api_package_owner.erl
  24. +2
    -2
      src/vendored/r3_hex_api_release.erl
  25. +1
    -1
      src/vendored/r3_hex_api_user.erl
  26. +5
    -8
      src/vendored/r3_hex_core.erl
  27. +2
    -2
      src/vendored/r3_hex_core.hrl
  28. +1
    -1
      src/vendored/r3_hex_erl_tar.erl
  29. +1
    -1
      src/vendored/r3_hex_erl_tar.hrl
  30. +1
    -1
      src/vendored/r3_hex_filename.erl
  31. +13
    -3
      src/vendored/r3_hex_http.erl
  32. +1
    -1
      src/vendored/r3_hex_http_httpc.erl
  33. +175
    -31
      src/vendored/r3_hex_pb_names.erl
  34. +474
    -173
      src/vendored/r3_hex_pb_package.erl
  35. +160
    -23
      src/vendored/r3_hex_pb_signed.erl
  36. +176
    -32
      src/vendored/r3_hex_pb_versions.erl
  37. +3
    -3
      src/vendored/r3_hex_registry.erl
  38. +2
    -2
      src/vendored/r3_hex_repo.erl
  39. +2
    -2
      src/vendored/r3_hex_tarball.erl
  40. +1
    -1
      src/vendored/r3_safe_erl_term.xrl
  41. +9
    -9
      test/rebar_pkg_repos_SUITE.erl
  42. +10
    -58
      vendor_hex_core.sh

+ 2
- 2
.gitignore 查看文件

@ -23,5 +23,5 @@ ebin
.edts
env
# hex_core artifact
src/r3_safe_erl_term.erl
# hex_core artifact
src/vendored/r3_safe_erl_term.erl

+ 2
- 2
rebar.config 查看文件

@ -43,10 +43,10 @@
{edoc_opts, [preprocess]}.
%% Use OTP 18+ when dialyzing rebar3
%% Use OTP 23+ when dialyzing rebar3
{dialyzer, [
{warnings, [unknown]},
{exclude_mods, [rebar_prv_alias]}
{plt_extra_apps, [parsetools, public_key]}
]}.
%% Keep only the logs of the last 5 runs

+ 3
- 3
src/rebar.hrl 查看文件

@ -39,14 +39,14 @@
%% the package record is used in a select match spec which upsets dialyzer
%% this is the suggested workaround from Tobias
%% http://erlang.org/pipermail/erlang-questions/2009-February/041445.html
-type ms_field() :: '$1' | '_'.
-type ms_field() :: '$1' | '_' | {'$1', '$2'}.
%% TODO: change package and requirement keys to be required (:=) after dropping support for OTP-18
-record(package, {key :: {unicode:unicode_binary() | ms_field(), unicode:unicode_binary() | ms_field(),
-record(package, {key :: {unicode:unicode_binary() | ms_field(), unicode:unicode_binary() | ms_field() | ec_semver:semver(),
unicode:unicode_binary() | ms_field()},
inner_checksum :: binary() | ms_field(),
outer_checksum :: binary() | ms_field(),
retired :: boolean() | ms_field(),
retired :: boolean() | ms_field() | #{reason := atom()},
dependencies :: [#{package => unicode:unicode_binary(),
requirement => unicode:unicode_binary()}] | ms_field()}).

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

@ -103,6 +103,6 @@ processing_base_dir(State) ->
%% @doc returns the SSL options adequate for the project based on
%% its configuration, including for validation of certs.
-spec ssl_opts(string()) -> [term()].
-spec ssl_opts(string() | binary()) -> [term()].
ssl_opts(Url) ->
rebar_utils:ssl_opts(Url).

+ 15
- 14
src/rebar_app_info.erl 查看文件

@ -82,13 +82,14 @@
project_type/0]).
-type project_type() :: rebar3 | mix | undefined.
-type app_vsn() :: binary() | string() | {git, short} | {git, long}.
-record(app_info_t, {name :: binary() | undefined,
app_file_src :: file:filename_all() | undefined,
app_file_src_script:: file:filename_all() | undefined,
app_file :: file:filename_all() | undefined,
original_vsn :: binary() | undefined,
vsn :: binary() | undefined,
original_vsn :: app_vsn() | undefined,
vsn :: app_vsn() | undefined,
parent=root :: binary() | root,
app_details=[] :: list(),
applications=[] :: list(),
@ -130,7 +131,7 @@ new(AppName) ->
{ok, #app_info_t{name=rebar_utils:to_binary(AppName)}}.
%% @doc Build a new app info value with only the name and version set.
-spec new(atom() | binary() | string(), binary() | string()) ->
-spec new(atom() | binary() | string(), app_vsn()) ->
{ok, t()}.
new(AppName, Vsn) ->
{ok, #app_info_t{name=rebar_utils:to_binary(AppName),
@ -138,7 +139,7 @@ new(AppName, Vsn) ->
original_vsn=Vsn}}.
%% @doc build a complete version of the app info with all fields set.
-spec new(atom() | binary() | string(), binary() | string(), file:name()) ->
-spec new(atom() | binary() | string(), app_vsn(), file:name()) ->
{ok, t()}.
new(AppName, Vsn, Dir) ->
{ok, #app_info_t{name=rebar_utils:to_binary(AppName),
@ -150,7 +151,7 @@ new(AppName, Vsn, Dir) ->
ebin_dir=filename:join(rebar_utils:to_list(Dir), "ebin")}}.
%% @doc build a complete version of the app info with all fields set.
-spec new(atom() | binary() | string(), binary() | string(), file:name(), list()) ->
-spec new(atom() | binary() | string(), app_vsn(), file:name(), list()) ->
{ok, t()}.
new(AppName, Vsn, Dir, Deps) ->
{ok, #app_info_t{name=rebar_utils:to_binary(AppName),
@ -163,7 +164,7 @@ new(AppName, Vsn, Dir, Deps) ->
deps=Deps}}.
%% @doc build a complete version of the app info with all fields set.
-spec new(atom() | binary(), atom() | binary() | string(), binary() | string(), file:name(), list()) ->
-spec new(atom() | binary(), atom() | binary() | string(), app_vsn(), file:name(), list()) ->
{ok, t()}.
new(Parent, AppName, Vsn, Dir, Deps) ->
{ok, #app_info_t{name=rebar_utils:to_binary(AppName),
@ -177,13 +178,13 @@ new(Parent, AppName, Vsn, Dir, Deps) ->
deps=Deps}}.
-spec app_to_map(t()) -> #{name := atom(),
vsn := string(),
vsn := app_vsn(),
applications := [atom()],
included_applications := [atom()],
dir := file:name(),
out_dir := file:name(),
ebin_dir := file:name(),
link := boolean()}.
link := false}.
app_to_map(#app_info_t{name=Name,
vsn=Vsn,
applications=Applications,
@ -425,23 +426,23 @@ parent(AppInfo=#app_info_t{}, Parent) ->
%% @doc returns the original version of the app (unevaluated if
%% asking for a semver)
-spec original_vsn(t()) -> binary().
-spec original_vsn(t()) -> app_vsn().
original_vsn(#app_info_t{original_vsn=Vsn}) ->
Vsn.
%% @doc stores the original version of the app (unevaluated if
%% asking for a semver)
-spec original_vsn(t(), binary() | string()) -> t().
-spec original_vsn(t(), app_vsn()) -> t().
original_vsn(AppInfo=#app_info_t{}, Vsn) ->
AppInfo#app_info_t{original_vsn=Vsn}.
%% @doc returns the version of the app after evaluation
-spec vsn(t()) -> binary().
-spec vsn(t()) -> app_vsn().
vsn(#app_info_t{vsn=Vsn}) ->
Vsn.
%% @doc sets the evaluated vsn of the app
-spec vsn(t(), binary() | string()) -> t().
-spec vsn(t(), app_vsn()) -> t().
vsn(AppInfo=#app_info_t{}, Vsn) ->
AppInfo#app_info_t{vsn=Vsn}.
@ -505,7 +506,7 @@ fetch_dir(#app_info_t{fetch_dir=FetchDir}) ->
FetchDir.
%% @doc returns the directory to fetch the dep source to
-spec fetch_dir(t(), file:name()) -> file:name().
-spec fetch_dir(t(), file:name()) -> t().
fetch_dir(AppInfo=#app_info_t{}, FetchDir) ->
AppInfo#app_info_t{fetch_dir=FetchDir}.
@ -559,7 +560,7 @@ source(#app_info_t{source=Source}) ->
Source.
%% @doc sets the source specification for the app
-spec source(t(), string() | tuple() | checkout) -> t().
-spec source(t(), string() | tuple() | checkout | undefined) -> t().
source(AppInfo=#app_info_t{}, Source) ->
AppInfo#app_info_t{source=Source}.

+ 3
- 1
src/rebar_app_utils.erl 查看文件

@ -315,7 +315,9 @@ expand_deps_sources(Dep, State) ->
%% around version if required.
-spec update_source(rebar_app_info:t(), Source, rebar_state:t()) ->
rebar_app_info:t() when
Source :: rebar_resource_v2:source().
Source :: rebar_resource_v2:source()
| {pkg, PkgName::string(), PkgVsn::unicode:unicode_binary(), Hash::undefined|binary()}
| {pkg, PkgName::string(), PkgVsn::unicode:unicode_binary(), OldHash::undefined|binary(), Hash::undefined|binary()}.
update_source(AppInfo, {pkg, PkgName, PkgVsn, Hash}, State) ->
update_source(AppInfo, {pkg, PkgName, PkgVsn, undefined, Hash}, State);
update_source(AppInfo, {pkg, PkgName, PkgVsn, OldHash, Hash}, State) ->

+ 5
- 5
src/rebar_compiler.erl 查看文件

@ -18,8 +18,8 @@
-type extension() :: string().
-type out_mappings() :: [{extension(), file:filename()}].
-callback context(rebar_app_info:t()) -> #{src_dirs => [file:dirname()], % mandatory
include_dirs => [file:dirname()], % mandatory
-callback context(rebar_app_info:t()) -> #{src_dirs => [DirName :: file:filename()], % mandatory
include_dirs => [DirName :: file:filename()], % mandatory
src_ext => extension(), % mandatory
out_mappings => out_mappings(), % mandatory
dependencies_opts => term()}. % optional
@ -29,8 +29,8 @@
{[file:filename()] | % [Sequential]
{[file:filename()], [file:filename()]}, % {Sequential, Parallel}
term()}}.
-callback dependencies(file:filename(), file:dirname(), [file:dirname()]) -> [file:filename()].
-callback dependencies(file:filename(), file:dirname(), [file:dirname()], term()) -> [file:filename()].
-callback dependencies(file:filename(), DirName :: file:filename(), [DirName :: file:filename()]) -> [file:filename()].
-callback dependencies(file:filename(), DirName :: file:filename(), [DirName :: file:filename()], term()) -> [file:filename()].
-callback compile(file:filename(), out_mappings(), rebar_dict(), list()) ->
ok | {ok, [string()]} | error | {error, [string()], [string()]} | skipped.
-callback compile_and_track(file:filename(), out_mappings(), rebar_dict(), list()) ->
@ -115,7 +115,7 @@ clean(Compilers, AppInfo) ->
%% These functions are here for the ultimate goal of getting rid of
%% rebar_base_compiler. This can't be done because of existing plugins.
-spec needs_compile(filename:all(), extension(), [{extension(), file:dirname()}]) -> boolean().
-spec needs_compile(file:name_all(), extension(), [{extension(), DirName :: file:filename()}]) -> boolean().
needs_compile(Source, OutExt, Mappings) ->
Ext = filename:extension(Source),
BaseName = filename:basename(Source, Ext),

+ 3
- 0
src/rebar_compiler_dag.erl 查看文件

@ -247,6 +247,7 @@ compile_order(G, AppDefs) ->
AppPaths = prepare_app_paths(AppDefs),
compile_order(Edges, AppPaths, #{}).
-dialyzer({no_opaque, maybe_store/5}). % optimized digraph usage breaks opacity
%% @doc Store the DAG on disk if it was dirty
maybe_store(G, Dir, Compiler, Label, CritMeta) ->
case is_dirty(G) of
@ -281,6 +282,7 @@ dag_file(Dir, CompilerMod, Label) ->
filename:join([rebar_dir:local_cache_dir(Dir), CompilerMod,
?DAG_ROOT ++ "_" ++ Label ++ ?DAG_EXT]).
-dialyzer({no_opaque, restore_dag/3}). % optimized digraph usage breaks opacity
restore_dag(G, File, CritMeta) ->
case file:read_file(File) of
{ok, Data} ->
@ -298,6 +300,7 @@ restore_dag(G, File, CritMeta) ->
ok
end.
-dialyzer([{no_opaque, store_dag/3}, {no_return, store_dag/3}]). % optimized digraph usage breaks opacity
store_dag(G, File, CritMeta) ->
ok = filelib:ensure_dir(File),
{digraph, VT, ET, NT, false} = G,

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

@ -516,7 +516,7 @@ resolve_link(Path) ->
split_dirname(Path) ->
{filename:dirname(Path), filename:basename(Path)}.
-spec ensure_dir(filelib:dirname_all()) -> ok | {error, file:posix()}.
-spec ensure_dir(file:name_all()) -> ok | {error, file:posix()}.
ensure_dir(Path) ->
filelib:ensure_dir(filename:join(Path, "fake_file")).

+ 2
- 2
src/rebar_git_resource.erl 查看文件

@ -124,7 +124,7 @@ parse_git_url(not_scp, Url) ->
case rebar_uri:parse(Url, UriOpts) of
#{path := Path, host := Host} ->
{ok, {Host, filename:rootname(Path, ".git")}};
{error, Reason} ->
{error, _, Reason} ->
{error, Reason}
end.
@ -174,7 +174,7 @@ maybe_warn_local_url(Url) ->
"Use remote git resources, or a plugin for local dependencies.",
case parse_git_url(Url) of
{error, no_scheme} -> ?WARN(WarnStr, [Url]);
{error, {no_default_port, _, _}} -> ?WARN(WarnStr, [Url]);
{error, no_default_port} -> ?WARN(WarnStr, [Url]);
{error, {malformed_url, _, _}} -> ?WARN(WarnStr, [Url]);
_ -> ok
end.

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

@ -267,8 +267,10 @@ update_package(Name, RepoConfig=#{name := Repo}, State) ->
fail
end.
get_package_repo_config(RepoConfig=#{mirror_of := Repo}) ->
get_package_repo_config(maps:remove(mirror_of, RepoConfig#{name => Repo}));
get_package_repo_config(RepoConfig=#{mirror_of := _}) ->
get_package_repo_config(maps:remove(mirror_of, RepoConfig));
get_package_repo_config(RepoConfig=#{name := _}) ->
get_package_repo_config(maps:remove(name, RepoConfig));
get_package_repo_config(RepoConfig) ->
RepoConfig.

+ 2
- 6
src/rebar_paths.erl 查看文件

@ -1,7 +1,7 @@
-module(rebar_paths).
-include("rebar.hrl").
-type target() :: deps | plugins.
-type target() :: deps | plugins | runtime.
-type targets() :: [target(), ...].
-export_type([target/0, targets/0]).
-export([set_paths/2, unset_paths/2]).
@ -209,11 +209,7 @@ get_apps(deps, State) ->
%% The code paths for deps also include the top level apps
%% and the extras, which we don't have here; we have to
%% add the apps by hand
case rebar_state:project_apps(State) of
undefined -> [];
List -> List
end ++
rebar_state:all_deps(State);
rebar_state:project_apps(State) ++ rebar_state:all_deps(State);
get_apps(plugins, State) ->
rebar_state:all_plugin_deps(State);
get_apps(runtime, State) ->

+ 6
- 6
src/rebar_pkg_resource.erl 查看文件

@ -20,7 +20,7 @@
-include("rebar.hrl").
-include_lib("providers/include/providers.hrl").
-type package() :: {pkg, binary(), binary(), binary(), rebar_hex_repos:repo()}.
-type package() :: {pkg, binary(), binary(), binary(), binary(), rebar_hex_repos:repo()}.
%%==============================================================================
%% Public API
@ -29,10 +29,9 @@
-spec init(atom(), rebar_state:t()) -> {ok, rebar_resource_v2:resource()}.
init(Type, State) ->
{ok, Vsn} = application:get_key(rebar, vsn),
BaseConfig = #{http_adapter => r3_hex_http_httpc,
BaseConfig = #{http_adapter => {r3_hex_http_httpc, #{profile => rebar}},
http_user_agent_fragment =>
<<"(rebar3/", (list_to_binary(Vsn))/binary, ") (httpc)">>,
http_adapter_config => #{profile => rebar}},
<<"(rebar3/", (list_to_binary(Vsn))/binary, ") (httpc)">>},
Repos = rebar_hex_repos:from_state(BaseConfig, State),
Resource = rebar_resource_v2:new(Type, ?MODULE, #{repos => Repos,
base_config => BaseConfig}),
@ -43,7 +42,7 @@ init(Type, State) ->
-spec lock(AppInfo, ResourceState) -> Res when
AppInfo :: rebar_app_info:t(),
ResourceState :: rebar_resource_v2:resource_state(),
Res :: {atom(), string(), any(), binary()}.
Res :: {atom(), string(), any(), binary(), binary()}.
lock(AppInfo, _) ->
{pkg, Name, Vsn, OldHash, Hash, _RepoConfig} = rebar_app_info:source(AppInfo),
{pkg, Name, Vsn, OldHash, Hash}.
@ -209,7 +208,8 @@ store_etag_in_cache(Path, ETag) ->
ETag :: binary(),
ETagPath :: file:name(),
UpdateETag :: boolean(),
Res :: ok | {unexpected_hash, integer(), integer()} | {fetch_fail, binary(), binary()}.
Res :: ok | {unexpected_hash, integer(), integer()} | {fetch_fail, binary(), binary()}
| {bad_registry_checksum, integer(), integer()} | {error, _}.
cached_download(TmpDir, CachePath, Pkg={pkg, Name, Vsn, _OldHash, _Hash, RepoConfig}, State, ETag,
ETagPath, UpdateETag) ->
CDN = maybe_default_cdn(State),

+ 3
- 1
src/rebar_prv_alias.erl 查看文件

@ -22,6 +22,7 @@ init(State) ->
end
end, {ok, State}, Aliases).
-dialyzer([{no_opaque, init_alias/3}, {no_return, init_alias/3}]). % warnings relate to use of opaque structures in :forms
init_alias(Alias, Cmds, State) ->
Module = list_to_atom("rebar_prv_alias_" ++ atom_to_list(Alias)),
@ -65,10 +66,11 @@ validate_provider(Alias, Cmds, State) ->
false
end.
-dialyzer({no_unused, example/1}). % required since we suppress warnings for init_alias/3
example(Alias) ->
"rebar3 " ++ atom_to_list(Alias).
-dialyzer({no_unused, desc/1}). % required since we suppress warnings for init_alias/3
desc(Cmds) ->
"Equivalent to running: rebar3 do "
++ rebar_string:join(lists:map(fun to_desc/1, Cmds), ",").

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

@ -97,7 +97,7 @@ build_plugin(ToBuild, State) ->
maybe_update_pkg(Tup, State) when is_tuple(Tup) ->
maybe_update_pkg(element(1, Tup), State);
maybe_update_pkg(Name, State) ->
try rebar_app_utils:parse_dep(root, ?DEFAULT_PLUGINS_DIR, Name, State, [], 0) of
try rebar_app_utils:parse_dep(root, unicode:characters_to_binary(?DEFAULT_PLUGINS_DIR), Name, State, [], 0) of
AppInfo ->
Source = rebar_app_info:source(AppInfo),
case element(1, Source) of

+ 2
- 1
src/rebar_resource_v2.erl 查看文件

@ -22,7 +22,8 @@
-include_lib("providers/include/providers.hrl").
-type resource() :: #resource{}.
-type source() :: {type(), location(), ref()} | {type(), location(), ref(), binary()}.
-type source() :: {type(), location(), ref()} | {type(), location(), ref(), binary()}
| {type(), location(), ref(), binary(), binary()}.
-type type() :: atom().
-type location() :: string().
-type ref() :: any().

+ 1
- 0
src/rebar_state.erl 查看文件

@ -492,6 +492,7 @@ add_provider(State=#state_t{providers=Providers, allow_provider_overrides=false}
State#state_t{providers=[Provider | Providers]}
end.
-dialyzer({no_match, create_logic_providers/2}). % we want to be permissive with providers:new/2
create_logic_providers(ProviderModules, State0) ->
try
lists:foldl(fun(ProviderMod, StateAcc) ->

+ 4
- 3
src/rebar_uri.erl 查看文件

@ -17,12 +17,13 @@ parse(URIString) ->
parse(URIString, URIOpts) ->
case uri_string:parse(URIString) of
#{path := ""} = Map -> apply_opts(Map#{path => "/"}, URIOpts);
Map -> apply_opts(Map, URIOpts)
Map when is_map(Map) -> apply_opts(Map, URIOpts);
{error, _, _} = E -> E
end.
-else.
-spec parse(URIString) -> URIMap when
URIString :: iodata(),
URIMap :: map() | {error, atom(), term()}.
URIMap :: map() | {error, term(), term()}.
parse(URIString) ->
parse(URIString, []).
@ -33,7 +34,7 @@ parse(URIString, URIOpts) ->
%% no additional parser/term info available to us,
%% e.g. see what uri_string returns in
%% uri_string:parse(<<"h$ttp:::://////lolz">>).
{error, Reason, ""};
{error, "", Reason};
{ok, {Scheme, UserInfo, Host, Port, Path, Query}} ->
#{
scheme => rebar_utils:to_list(Scheme),

+ 3
- 3
src/rebar_utils.erl 查看文件

@ -497,7 +497,7 @@ reread_logger_config() ->
%% -- primary config is used for settings shared across handlers
LogLvlPrimary = proplists:get_value(logger_level, KernelCfg, all),
{FilterDefault, Filters} =
case lists:keyfind(filters, 1, KernelCfg) of
case lists:keyfind(filters, 1, LogCfg) of
false -> {log, []};
{filters, FoundDef, FoundFilter} -> {FoundDef, FoundFilter}
end,
@ -1027,7 +1027,7 @@ is_list_of_strings(List) when is_list(List) ->
%% @end
%%------------------------------------------------------------------------------
-spec ssl_opts(Url) -> Res when
Url :: string(),
Url :: string() | binary(),
Res :: proplists:proplist().
ssl_opts(Url) ->
case get_ssl_config() of
@ -1045,7 +1045,7 @@ ssl_opts(Url) ->
%%------------------------------------------------------------------------------
-spec ssl_opts(Enabled, Url) -> Res when
Enabled :: atom(),
Url :: string(),
Url :: string() | binary(),
Res :: proplists:proplist().
ssl_opts(ssl_verify_enabled, Url) ->
case check_ssl_version() of

+ 1
- 1
src/vendored/r3_hex_api.erl 查看文件

@ -1,4 +1,4 @@
%% Vendored from hex_core v0.7.0, do not edit manually
%% Vendored from hex_core v0.7.1, do not edit manually
%% @hidden

+ 1
- 1
src/vendored/r3_hex_api_key.erl 查看文件

@ -1,4 +1,4 @@
%% Vendored from hex_core v0.7.0, do not edit manually
%% Vendored from hex_core v0.7.1, do not edit manually
-module(r3_hex_api_key).
-export([

+ 1
- 1
src/vendored/r3_hex_api_package.erl 查看文件

@ -1,4 +1,4 @@
%% Vendored from hex_core v0.7.0, do not edit manually
%% Vendored from hex_core v0.7.1, do not edit manually
-module(r3_hex_api_package).
-export([get/2, search/3]).

+ 1
- 1
src/vendored/r3_hex_api_package_owner.erl 查看文件

@ -1,4 +1,4 @@
%% Vendored from hex_core v0.7.0, do not edit manually
%% Vendored from hex_core v0.7.1, do not edit manually
-module(r3_hex_api_package_owner).
-export([

+ 2
- 2
src/vendored/r3_hex_api_release.erl 查看文件

@ -1,4 +1,4 @@
%% Vendored from hex_core v0.7.0, do not edit manually
%% Vendored from hex_core v0.7.1, do not edit manually
-module(r3_hex_api_release).
-export([
@ -108,7 +108,7 @@ publish(Config, Tarball) -> publish(Config, Tarball, []).
%% }}}
%% '''
%% @end
-spec publish(hexcore:config(), binary(), publish_params()) -> r3_hex_api:response().
-spec publish(r3_hex_core:config(), binary(), publish_params()) -> r3_hex_api:response().
publish(Config, Tarball, Params) when is_map(Config) andalso is_binary(Tarball) andalso is_list(Params)->
QueryString = r3_hex_api:encode_query_string([{replace, proplists:get_value(replace, Params, false)}]),
Path = r3_hex_api:join_path_segments(r3_hex_api:build_repository_path(Config, ["publish"])),

+ 1
- 1
src/vendored/r3_hex_api_user.erl 查看文件

@ -1,4 +1,4 @@
%% Vendored from hex_core v0.7.0, do not edit manually
%% Vendored from hex_core v0.7.1, do not edit manually
-module(r3_hex_api_user).
-export([

+ 5
- 8
src/vendored/r3_hex_core.erl 查看文件

@ -1,4 +1,4 @@
%% Vendored from hex_core v0.7.0, do not edit manually
%% Vendored from hex_core v0.7.1, do not edit manually
%% @doc
%% hex_core entrypoint module.
@ -18,11 +18,10 @@
%% * `api_repository' - Name of the repository endpoint in the API, this should
%% for example be set when accessing packages from a specific repository.
%% * `api_url' - URL to the HTTP API (default: `https://hex.pm/api').
%% * `http_adapter' - Callback module used for HTTP requests, see [`r3_hex_http'](r3_hex_http.html)
%% (default: `r3_hex_http_httpc').
%% * `http_adapter' - A tuple of a callback module used for HTTP requests, see [`r3_hex_http'](r3_hex_http.html)
%% (default: `r3_hex_http_httpc') and the configuration to pass to the HTTP adapter.
%% * `http_etag' - Sets the `if-none-match' HTTP header with the given value to do a
%% conditional HTTP request.
%% * `http_adapter_config' - Configuration to pass to the HTTP adapter.
%% * `http_user_agent_fragment' - Will be appended to the `user-agent` HTTP header (default: `(httpc)').
%% * `repo_key' - Authentication key used when accessing the repository.
%% * `repo_name' - Name of the repository, used for verifying the repository signature
@ -58,9 +57,8 @@ J1i2xWFndWa6nfFnRxZmCStCOZWYYPlaxr+FZceFbpMwzTNs4g3d4tLNUcbKAIH4
api_organization => binary() | undefined,
api_repository => binary() | undefined,
api_url => binary(),
http_adapter => module(),
http_adapter => {module(), map()},
http_etag => binary() | undefined,
http_adapter_config => map(),
http_headers => map(),
http_user_agent_fragment => binary(),
repo_key => binary() | undefined,
@ -81,8 +79,7 @@ default_config() ->
api_organization => undefined,
api_repository => undefined,
api_url => <<"https://hex.pm/api">>,
http_adapter => r3_hex_http_httpc,
http_adapter_config => #{profile => default},
http_adapter => {r3_hex_http_httpc, #{profile => default}},
http_etag => undefined,
http_headers => #{},
http_user_agent_fragment => <<"(httpc)">>,

+ 2
- 2
src/vendored/r3_hex_core.hrl 查看文件

@ -1,3 +1,3 @@
%% Vendored from hex_core v0.7.0, do not edit manually
%% Vendored from hex_core v0.7.1, do not edit manually
-define(HEX_CORE_VERSION, "0.7.0").
-define(HEX_CORE_VERSION, "0.7.1").

+ 1
- 1
src/vendored/r3_hex_erl_tar.erl 查看文件

@ -1,4 +1,4 @@
%% Vendored from hex_core v0.7.0, do not edit manually
%% Vendored from hex_core v0.7.1, do not edit manually
%% @private
%% Copied from https://github.com/erlang/otp/blob/OTP-20.0.1/lib/stdlib/src/erl_tar.erl

+ 1
- 1
src/vendored/r3_hex_erl_tar.hrl 查看文件

@ -1,4 +1,4 @@
%% Vendored from hex_core v0.7.0, do not edit manually
%% Vendored from hex_core v0.7.1, do not edit manually
% Copied from https://github.com/erlang/otp/blob/OTP-20.0.1/lib/stdlib/src/erl_tar.hrl

+ 1
- 1
src/vendored/r3_hex_filename.erl 查看文件

@ -1,4 +1,4 @@
%% Vendored from hex_core v0.7.0, do not edit manually
%% Vendored from hex_core v0.7.1, do not edit manually
% @private
% Excerpt from https://github.com/erlang/otp/blob/OTP-20.0.1/lib/stdlib/src/filename.erl#L761-L788

+ 13
- 3
src/vendored/r3_hex_http.erl 查看文件

@ -1,4 +1,4 @@
%% Vendored from hex_core v0.7.0, do not edit manually
%% Vendored from hex_core v0.7.1, do not edit manually
-module(r3_hex_http).
-export([request/5]).
@ -9,7 +9,9 @@
-type method() :: get | post | put | patch | delete.
-type status() :: non_neg_integer().
-export_type([status/0]).
-type headers() :: #{binary() => binary()}.
-export_type([headers/0]).
-type body() :: {ContentType :: binary(), Body :: binary()} | undefined.
-type adapter_config() :: map().
@ -20,10 +22,18 @@
-spec request(r3_hex_core:config(), method(), URI :: binary(), headers(), body()) ->
{ok, {status(), headers(), binary()}} | {error, term()}.
request(Config, Method, URI, Headers, Body) when is_binary(URI) and is_map(Headers) ->
Adapter = maps:get(http_adapter, Config),
{Adapter, AdapterConfig} = case maps:get(http_adapter, Config, {r3_hex_http_httpc, #{}}) of
{Adapter0, AdapterConfig0} ->
{Adapter0, AdapterConfig0};
%% TODO: remove in v0.9
Adapter0 when is_atom(Adapter0) ->
AdapterConfig0 = maps:get(http_adapter_config, Config, #{}),
io:format("[r3_hex_http] setting #{http_adapter => Module, http_adapter_config => Map} "
"is deprecated in favour of #{http_adapter => {Module, Map}}~n"),
{Adapter0, AdapterConfig0}
end,
UserAgentFragment = maps:get(http_user_agent_fragment, Config),
Headers2 = put_new(<<"user-agent">>, user_agent(UserAgentFragment), Headers),
AdapterConfig = maps:get(http_adapter_config, Config, #{}),
Adapter:request(Method, URI, Headers2, Body, AdapterConfig).
user_agent(UserAgentFragment) ->

+ 1
- 1
src/vendored/r3_hex_http_httpc.erl 查看文件

@ -1,4 +1,4 @@
%% Vendored from hex_core v0.7.0, do not edit manually
%% Vendored from hex_core v0.7.1, do not edit manually
%% @hidden

+ 175
- 31
src/vendored/r3_hex_pb_names.erl 查看文件

@ -1,8 +1,9 @@
%% Vendored from hex_core v0.7.0, do not edit manually
%% Vendored from hex_core v0.7.1, do not edit manually
%% -*- coding: utf-8 -*-
%% @private
%% Automatically generated, do not edit
%% Generated by gpb_compile version 4.3.1
%% Generated by gpb_compile version 4.10.0
-module(r3_hex_pb_names).
-export([encode_msg/2, encode_msg/3]).
@ -21,7 +22,28 @@
-export([get_service_def/1]).
-export([get_rpc_names/1]).
-export([find_rpc_def/2, fetch_rpc_def/2]).
-export([fqbin_to_service_name/1]).
-export([service_name_to_fqbin/1]).
-export([fqbins_to_service_and_rpc_name/2]).
-export([service_and_rpc_name_to_fqbins/2]).
-export([fqbin_to_msg_name/1]).
-export([msg_name_to_fqbin/1]).
-export([fqbin_to_enum_name/1]).
-export([enum_name_to_fqbin/1]).
-export([get_package_name/0]).
-export([uses_packages/0]).
-export([source_basename/0]).
-export([get_all_source_basenames/0]).
-export([get_all_proto_names/0]).
-export([get_msg_containment/1]).
-export([get_pkg_containment/1]).
-export([get_service_containment/1]).
-export([get_rpc_containment/1]).
-export([get_enum_containment/1]).
-export([get_proto_by_msg_name_as_fqbin/1]).
-export([get_proto_by_service_name_as_fqbin/1]).
-export([get_proto_by_enum_name_as_fqbin/1]).
-export([get_protos_by_pkg_name_as_fqbin/1]).
-export([gpb_version_as_string/0, gpb_version_as_list/0]).
@ -32,11 +54,11 @@
%% message types
-type 'Names'() ::
#{packages => ['Package'()], % = 1
repository => iodata() % = 2
repository := iodata() % = 2
}.
-type 'Package'() ::
#{name => iodata() % = 1
#{name := iodata() % = 1
}.
-export_type(['Names'/0, 'Package'/0]).
@ -50,17 +72,19 @@ encode_msg(Msg, MsgName, Opts) ->
verify_msg(Msg, MsgName, Opts),
TrUserData = proplists:get_value(user_data, Opts),
case MsgName of
'Names' -> e_msg_Names(id(Msg, TrUserData), TrUserData);
'Names' ->
encode_msg_Names(id(Msg, TrUserData), TrUserData);
'Package' ->
e_msg_Package(id(Msg, TrUserData), TrUserData)
encode_msg_Package(id(Msg, TrUserData), TrUserData)
end.
e_msg_Names(Msg, TrUserData) ->
e_msg_Names(Msg, <<>>, TrUserData).
encode_msg_Names(Msg, TrUserData) ->
encode_msg_Names(Msg, <<>>, TrUserData).
e_msg_Names(#{repository := F2} = M, Bin, TrUserData) ->
encode_msg_Names(#{repository := F2} = M, Bin,
TrUserData) ->
B1 = case M of
#{packages := F1} ->
TrF1 = id(F1, TrUserData),
@ -74,18 +98,18 @@ e_msg_Names(#{repository := F2} = M, Bin, TrUserData) ->
e_type_string(TrF2, <<B1/binary, 18>>, TrUserData)
end.
e_msg_Package(Msg, TrUserData) ->
e_msg_Package(Msg, <<>>, TrUserData).
encode_msg_Package(Msg, TrUserData) ->
encode_msg_Package(Msg, <<>>, TrUserData).
e_msg_Package(#{name := F1}, Bin, TrUserData) ->
encode_msg_Package(#{name := F1}, Bin, TrUserData) ->
begin
TrF1 = id(F1, TrUserData),
e_type_string(TrF1, <<Bin/binary, 10>>, TrUserData)
end.
e_mfield_Names_packages(Msg, Bin, TrUserData) ->
SubBin = e_msg_Package(Msg, <<>>, TrUserData),
SubBin = encode_msg_Package(Msg, <<>>, TrUserData),
Bin2 = e_varint(byte_size(SubBin), Bin),
<<Bin2/binary, SubBin/binary>>.
@ -203,12 +227,6 @@ decode_msg_1_catch(Bin, MsgName, TrUserData) ->
catch Class:Reason:StackTrace -> error({gpb_error,{decoding_failure, {Bin, MsgName, {Class, Reason, StackTrace}}}})
end.
-else.
-ifdef('GPB_PATTERN_STACK').
decode_msg_1_catch(Bin, MsgName, TrUserData) ->
try decode_msg_2_doit(MsgName, Bin, TrUserData)
catch Class:Reason:StackTrace -> error({gpb_error,{decoding_failure, {Bin, MsgName, {Class, Reason, StackTrace}}}})
end.
-else.
decode_msg_1_catch(Bin, MsgName, TrUserData) ->
try decode_msg_2_doit(MsgName, Bin, TrUserData)
catch Class:Reason ->
@ -217,16 +235,14 @@ decode_msg_1_catch(Bin, MsgName, TrUserData) ->
end.
-endif.
-endif.
decode_msg_2_doit('Names', Bin, TrUserData) ->
id(d_msg_Names(Bin, TrUserData), TrUserData);
id(decode_msg_Names(Bin, TrUserData), TrUserData);
decode_msg_2_doit('Package', Bin, TrUserData) ->
id(d_msg_Package(Bin, TrUserData), TrUserData).
id(decode_msg_Package(Bin, TrUserData), TrUserData).
d_msg_Names(Bin, TrUserData) ->
decode_msg_Names(Bin, TrUserData) ->
dfp_read_field_def_Names(Bin, 0, 0, id([], TrUserData),
id('$undef', TrUserData), TrUserData).
@ -295,7 +311,7 @@ d_field_Names_packages(<<0:1, X:7, Rest/binary>>, N,
{NewFValue, RestF} = begin
Len = X bsl N + Acc,
<<Bs:Len/binary, Rest2/binary>> = Rest,
{id(d_msg_Package(Bs, TrUserData), TrUserData),
{id(decode_msg_Package(Bs, TrUserData), TrUserData),
Rest2}
end,
dfp_read_field_def_Names(RestF, 0, 0,
@ -353,7 +369,7 @@ skip_64_Names(<<_:64, Rest/binary>>, Z1, Z2, F@_1, F@_2,
dfp_read_field_def_Names(Rest, Z1, Z2, F@_1, F@_2,
TrUserData).
d_msg_Package(Bin, TrUserData) ->
decode_msg_Package(Bin, TrUserData) ->
dfp_read_field_def_Package(Bin, 0, 0,
id('$undef', TrUserData), TrUserData).
@ -546,6 +562,7 @@ verify_msg(Msg, MsgName, Opts) ->
-compile({nowarn_unused_function,v_msg_Names/3}).
-dialyzer({nowarn_function,v_msg_Names/3}).
v_msg_Names(#{repository := F2} = M, Path,
TrUserData) ->
case M of
@ -576,6 +593,7 @@ v_msg_Names(X, Path, _TrUserData) ->
mk_type_error({expected_msg, 'Names'}, X, Path).
-compile({nowarn_unused_function,v_msg_Package/3}).
-dialyzer({nowarn_function,v_msg_Package/3}).
v_msg_Package(#{name := F1} = M, Path, TrUserData) ->
v_type_string(F1, [name | Path], TrUserData),
lists:foreach(fun (name) -> ok;
@ -592,6 +610,7 @@ v_msg_Package(X, Path, _TrUserData) ->
mk_type_error({expected_msg, 'Package'}, X, Path).
-compile({nowarn_unused_function,v_type_string/3}).
-dialyzer({nowarn_function,v_type_string/3}).
v_type_string(S, Path, _TrUserData)
when is_list(S); is_binary(S) ->
try unicode:characters_to_binary(S) of
@ -614,11 +633,12 @@ mk_type_error(Error, ValueSeen, Path) ->
-compile({nowarn_unused_function,prettify_path/1}).
-dialyzer({nowarn_function,prettify_path/1}).
prettify_path([]) -> top_level;
prettify_path(PathR) ->
list_to_atom(string:join(lists:map(fun atom_to_list/1,
lists:reverse(PathR)),
".")).
list_to_atom(lists:append(lists:join(".",
lists:map(fun atom_to_list/1,
lists:reverse(PathR))))).
-compile({nowarn_unused_function,id/2}).
@ -644,6 +664,7 @@ cons(Elem, Acc, _TrUserData) -> [Elem | Acc].
-compile({inline,'erlang_++'/3}).
'erlang_++'(A, B, _TrUserData) -> A ++ B.
get_msg_defs() ->
[{{msg, 'Names'},
[#{name => packages, fnum => 1, rnum => 2,
@ -724,12 +745,135 @@ fetch_rpc_def(ServiceName, RpcName) ->
erlang:error({no_such_rpc, ServiceName, RpcName}).
%% Convert a a fully qualified (ie with package name) service name
%% as a binary to a service name as an atom.
-spec fqbin_to_service_name(_) -> no_return().
fqbin_to_service_name(X) ->
error({gpb_error, {badservice, X}}).
%% Convert a service name as an atom to a fully qualified
%% (ie with package name) name as a binary.
-spec service_name_to_fqbin(_) -> no_return().
service_name_to_fqbin(X) ->
error({gpb_error, {badservice, X}}).
%% Convert a a fully qualified (ie with package name) service name
%% and an rpc name, both as binaries to a service name and an rpc
%% name, as atoms.
-spec fqbins_to_service_and_rpc_name(_, _) -> no_return().
fqbins_to_service_and_rpc_name(S, R) ->
error({gpb_error, {badservice_or_rpc, {S, R}}}).
%% Convert a service name and an rpc name, both as atoms,
%% to a fully qualified (ie with package name) service name and
%% an rpc name as binaries.
-spec service_and_rpc_name_to_fqbins(_, _) -> no_return().
service_and_rpc_name_to_fqbins(S, R) ->
error({gpb_error, {badservice_or_rpc, {S, R}}}).
fqbin_to_msg_name(<<"Names">>) -> 'Names';
fqbin_to_msg_name(<<"Package">>) -> 'Package';
fqbin_to_msg_name(E) -> error({gpb_error, {badmsg, E}}).
msg_name_to_fqbin('Names') -> <<"Names">>;
msg_name_to_fqbin('Package') -> <<"Package">>;
msg_name_to_fqbin(E) -> error({gpb_error, {badmsg, E}}).
-spec fqbin_to_enum_name(_) -> no_return().
fqbin_to_enum_name(E) ->
error({gpb_error, {badenum, E}}).
-spec enum_name_to_fqbin(_) -> no_return().
enum_name_to_fqbin(E) ->
error({gpb_error, {badenum, E}}).
get_package_name() -> undefined.
%% Whether or not the message names
%% are prepended with package name or not.
uses_packages() -> false.
source_basename() -> "r3_hex_pb_names.proto".
%% Retrieve all proto file names, also imported ones.
%% The order is top-down. The first element is always the main
%% source file. The files are returned with extension,
%% see get_all_proto_names/0 for a version that returns
%% the basenames sans extension
get_all_source_basenames() -> ["r3_hex_pb_names.proto"].
%% Retrieve all proto file names, also imported ones.
%% The order is top-down. The first element is always the main
%% source file. The files are returned sans .proto extension,
%% to make it easier to use them with the various get_xyz_containment
%% functions.
get_all_proto_names() -> ["r3_hex_pb_names"].
get_msg_containment("r3_hex_pb_names") ->
['Names', 'Package'];
get_msg_containment(P) ->
error({gpb_error, {badproto, P}}).
get_pkg_containment("r3_hex_pb_names") -> undefined;
get_pkg_containment(P) ->
error({gpb_error, {badproto, P}}).
get_service_containment("r3_hex_pb_names") -> [];
get_service_containment(P) ->
error({gpb_error, {badproto, P}}).
get_rpc_containment("r3_hex_pb_names") -> [];
get_rpc_containment(P) ->
error({gpb_error, {badproto, P}}).
get_enum_containment("r3_hex_pb_names") -> [];
get_enum_containment(P) ->
error({gpb_error, {badproto, P}}).
get_proto_by_msg_name_as_fqbin(<<"Names">>) ->
"r3_hex_pb_names";
get_proto_by_msg_name_as_fqbin(<<"Package">>) ->
"r3_hex_pb_names";
get_proto_by_msg_name_as_fqbin(E) ->
error({gpb_error, {badmsg, E}}).
-spec get_proto_by_service_name_as_fqbin(_) -> no_return().
get_proto_by_service_name_as_fqbin(E) ->
error({gpb_error, {badservice, E}}).
-spec get_proto_by_enum_name_as_fqbin(_) -> no_return().
get_proto_by_enum_name_as_fqbin(E) ->
error({gpb_error, {badenum, E}}).
-spec get_protos_by_pkg_name_as_fqbin(_) -> no_return().
get_protos_by_pkg_name_as_fqbin(E) ->
error({gpb_error, {badpkg, E}}).
gpb_version_as_string() ->
"4.3.1".
"4.10.0".
gpb_version_as_list() ->
[4,3,1].
[4,10,0].

+ 474
- 173
src/vendored/r3_hex_pb_package.erl
文件差異過大導致無法顯示
查看文件


+ 160
- 23
src/vendored/r3_hex_pb_signed.erl 查看文件

@ -1,8 +1,9 @@
%% Vendored from hex_core v0.7.0, do not edit manually
%% Vendored from hex_core v0.7.1, do not edit manually
%% -*- coding: utf-8 -*-
%% @private
%% Automatically generated, do not edit
%% Generated by gpb_compile version 4.3.1
%% Generated by gpb_compile version 4.10.0
-module(r3_hex_pb_signed).
-export([encode_msg/2, encode_msg/3]).
@ -21,7 +22,28 @@
-export([get_service_def/1]).
-export([get_rpc_names/1]).
-export([find_rpc_def/2, fetch_rpc_def/2]).
-export([fqbin_to_service_name/1]).
-export([service_name_to_fqbin/1]).
-export([fqbins_to_service_and_rpc_name/2]).
-export([service_and_rpc_name_to_fqbins/2]).
-export([fqbin_to_msg_name/1]).
-export([msg_name_to_fqbin/1]).
-export([fqbin_to_enum_name/1]).
-export([enum_name_to_fqbin/1]).
-export([get_package_name/0]).
-export([uses_packages/0]).
-export([source_basename/0]).
-export([get_all_source_basenames/0]).
-export([get_all_proto_names/0]).
-export([get_msg_containment/1]).
-export([get_pkg_containment/1]).
-export([get_service_containment/1]).
-export([get_rpc_containment/1]).
-export([get_enum_containment/1]).
-export([get_proto_by_msg_name_as_fqbin/1]).
-export([get_proto_by_service_name_as_fqbin/1]).
-export([get_proto_by_enum_name_as_fqbin/1]).
-export([get_protos_by_pkg_name_as_fqbin/1]).
-export([gpb_version_as_string/0, gpb_version_as_list/0]).
@ -31,8 +53,8 @@
%% message types
-type 'Signed'() ::
#{payload => iodata() % = 1
%% signature => iodata() % = 2
#{payload := iodata() class="p">, % = 1
signature => iodata() % = 2
}.
-export_type(['Signed'/0]).
@ -47,15 +69,16 @@ encode_msg(Msg, MsgName, Opts) ->
TrUserData = proplists:get_value(user_data, Opts),
case MsgName of
'Signed' ->
e_msg_Signed(id(Msg, TrUserData), TrUserData)
encode_msg_Signed(id(Msg, TrUserData), TrUserData)
end.
e_msg_Signed(Msg, TrUserData) ->
e_msg_Signed(Msg, <<>>, TrUserData).
encode_msg_Signed(Msg, TrUserData) ->
encode_msg_Signed(Msg, <<>>, TrUserData).
e_msg_Signed(#{payload := F1} = M, Bin, TrUserData) ->
encode_msg_Signed(#{payload := F1} = M, Bin,
TrUserData) ->
B1 = begin
TrF1 = id(F1, TrUserData),
e_type_bytes(TrF1, <<Bin/binary, 10>>, TrUserData)
@ -175,12 +198,6 @@ decode_msg_1_catch(Bin, MsgName, TrUserData) ->
catch Class:Reason:StackTrace -> error({gpb_error,{decoding_failure, {Bin, MsgName, {Class, Reason, StackTrace}}}})
end.
-else.
-ifdef('GPB_PATTERN_STACK').
decode_msg_1_catch(Bin, MsgName, TrUserData) ->
try decode_msg_2_doit(MsgName, Bin, TrUserData)
catch Class:Reason:StackTrace -> error({gpb_error,{decoding_failure, {Bin, MsgName, {Class, Reason, StackTrace}}}})
end.
-else.
decode_msg_1_catch(Bin, MsgName, TrUserData) ->
try decode_msg_2_doit(MsgName, Bin, TrUserData)
catch Class:Reason ->
@ -189,14 +206,12 @@ decode_msg_1_catch(Bin, MsgName, TrUserData) ->
end.
-endif.
-endif.
decode_msg_2_doit('Signed', Bin, TrUserData) ->
id(d_msg_Signed(Bin, TrUserData), TrUserData).
id(decode_msg_Signed(Bin, TrUserData), TrUserData).
d_msg_Signed(Bin, TrUserData) ->
decode_msg_Signed(Bin, TrUserData) ->
dfp_read_field_def_Signed(Bin, 0, 0,
id('$undef', TrUserData),
id('$undef', TrUserData), TrUserData).
@ -413,6 +428,7 @@ verify_msg(Msg, MsgName, Opts) ->
-compile({nowarn_unused_function,v_msg_Signed/3}).
-dialyzer({nowarn_function,v_msg_Signed/3}).
v_msg_Signed(#{payload := F1} = M, Path, TrUserData) ->
v_type_bytes(F1, [payload | Path], TrUserData),
case M of
@ -435,6 +451,7 @@ v_msg_Signed(X, Path, _TrUserData) ->
mk_type_error({expected_msg, 'Signed'}, X, Path).
-compile({nowarn_unused_function,v_type_bytes/3}).
-dialyzer({nowarn_function,v_type_bytes/3}).
v_type_bytes(B, _Path, _TrUserData) when is_binary(B) ->
ok;
v_type_bytes(B, _Path, _TrUserData) when is_list(B) ->
@ -451,11 +468,12 @@ mk_type_error(Error, ValueSeen, Path) ->
-compile({nowarn_unused_function,prettify_path/1}).
-dialyzer({nowarn_function,prettify_path/1}).
prettify_path([]) -> top_level;
prettify_path(PathR) ->
list_to_atom(string:join(lists:map(fun atom_to_list/1,
lists:reverse(PathR)),
".")).
list_to_atom(lists:append(lists:join(".",
lists:map(fun atom_to_list/1,
lists:reverse(PathR))))).
-compile({nowarn_unused_function,id/2}).
@ -481,6 +499,7 @@ cons(Elem, Acc, _TrUserData) -> [Elem | Acc].
-compile({inline,'erlang_++'/3}).
'erlang_++'(A, B, _TrUserData) -> A ++ B.
get_msg_defs() ->
[{{msg, 'Signed'},
[#{name => payload, fnum => 1, rnum => 2, type => bytes,
@ -553,12 +572,130 @@ fetch_rpc_def(ServiceName, RpcName) ->
erlang:error({no_such_rpc, ServiceName, RpcName}).
%% Convert a a fully qualified (ie with package name) service name
%% as a binary to a service name as an atom.
-spec fqbin_to_service_name(_) -> no_return().
fqbin_to_service_name(X) ->
error({gpb_error, {badservice, X}}).
%% Convert a service name as an atom to a fully qualified
%% (ie with package name) name as a binary.
-spec service_name_to_fqbin(_) -> no_return().
service_name_to_fqbin(X) ->
error({gpb_error, {badservice, X}}).
%% Convert a a fully qualified (ie with package name) service name
%% and an rpc name, both as binaries to a service name and an rpc
%% name, as atoms.
-spec fqbins_to_service_and_rpc_name(_, _) -> no_return().
fqbins_to_service_and_rpc_name(S, R) ->
error({gpb_error, {badservice_or_rpc, {S, R}}}).
%% Convert a service name and an rpc name, both as atoms,
%% to a fully qualified (ie with package name) service name and
%% an rpc name as binaries.
-spec service_and_rpc_name_to_fqbins(_, _) -> no_return().
service_and_rpc_name_to_fqbins(S, R) ->
error({gpb_error, {badservice_or_rpc, {S, R}}}).
fqbin_to_msg_name(<<"Signed">>) -> 'Signed';
fqbin_to_msg_name(E) -> error({gpb_error, {badmsg, E}}).
msg_name_to_fqbin('Signed') -> <<"Signed">>;
msg_name_to_fqbin(E) -> error({gpb_error, {badmsg, E}}).
-spec fqbin_to_enum_name(_) -> no_return().
fqbin_to_enum_name(E) ->
error({gpb_error, {badenum, E}}).
-spec enum_name_to_fqbin(_) -> no_return().
enum_name_to_fqbin(E) ->
error({gpb_error, {badenum, E}}).
get_package_name() -> undefined.
%% Whether or not the message names
%% are prepended with package name or not.
uses_packages() -> false.
source_basename() -> "r3_hex_pb_signed.proto".
%% Retrieve all proto file names, also imported ones.
%% The order is top-down. The first element is always the main
%% source file. The files are returned with extension,
%% see get_all_proto_names/0 for a version that returns
%% the basenames sans extension
get_all_source_basenames() -> ["r3_hex_pb_signed.proto"].
%% Retrieve all proto file names, also imported ones.
%% The order is top-down. The first element is always the main
%% source file. The files are returned sans .proto extension,
%% to make it easier to use them with the various get_xyz_containment
%% functions.
get_all_proto_names() -> ["r3_hex_pb_signed"].
get_msg_containment("r3_hex_pb_signed") -> ['Signed'];
get_msg_containment(P) ->
error({gpb_error, {badproto, P}}).
get_pkg_containment("r3_hex_pb_signed") -> undefined;
get_pkg_containment(P) ->
error({gpb_error, {badproto, P}}).
get_service_containment("r3_hex_pb_signed") -> [];
get_service_containment(P) ->
error({gpb_error, {badproto, P}}).
get_rpc_containment("r3_hex_pb_signed") -> [];
get_rpc_containment(P) ->
error({gpb_error, {badproto, P}}).
get_enum_containment("r3_hex_pb_signed") -> [];
get_enum_containment(P) ->
error({gpb_error, {badproto, P}}).
get_proto_by_msg_name_as_fqbin(<<"Signed">>) ->
"r3_hex_pb_signed";
get_proto_by_msg_name_as_fqbin(E) ->
error({gpb_error, {badmsg, E}}).
-spec get_proto_by_service_name_as_fqbin(_) -> no_return().
get_proto_by_service_name_as_fqbin(E) ->
error({gpb_error, {badservice, E}}).
-spec get_proto_by_enum_name_as_fqbin(_) -> no_return().
get_proto_by_enum_name_as_fqbin(E) ->
error({gpb_error, {badenum, E}}).
-spec get_protos_by_pkg_name_as_fqbin(_) -> no_return().
get_protos_by_pkg_name_as_fqbin(E) ->
error({gpb_error, {badpkg, E}}).
gpb_version_as_string() ->
"4.3.1".
"4.10.0".
gpb_version_as_list() ->
[4,3,1].
[4,10,0].

+ 176
- 32
src/vendored/r3_hex_pb_versions.erl 查看文件

@ -1,8 +1,9 @@
%% Vendored from hex_core v0.7.0, do not edit manually
%% Vendored from hex_core v0.7.1, do not edit manually
%% -*- coding: utf-8 -*-
%% @private
%% Automatically generated, do not edit
%% Generated by gpb_compile version 4.3.1
%% Generated by gpb_compile version 4.10.0
-module(r3_hex_pb_versions).
-export([encode_msg/2, encode_msg/3]).
@ -21,7 +22,28 @@
-export([get_service_def/1]).
-export([get_rpc_names/1]).
-export([find_rpc_def/2, fetch_rpc_def/2]).
-export([fqbin_to_service_name/1]).
-export([service_name_to_fqbin/1]).
-export([fqbins_to_service_and_rpc_name/2]).
-export([service_and_rpc_name_to_fqbins/2]).
-export([fqbin_to_msg_name/1]).
-export([msg_name_to_fqbin/1]).
-export([fqbin_to_enum_name/1]).
-export([enum_name_to_fqbin/1]).
-export([get_package_name/0]).
-export([uses_packages/0]).
-export([source_basename/0]).
-export([get_all_source_basenames/0]).
-export([get_all_proto_names/0]).
-export([get_msg_containment/1]).
-export([get_pkg_containment/1]).
-export([get_service_containment/1]).
-export([get_rpc_containment/1]).
-export([get_enum_containment/1]).
-export([get_proto_by_msg_name_as_fqbin/1]).
-export([get_proto_by_service_name_as_fqbin/1]).
-export([get_proto_by_enum_name_as_fqbin/1]).
-export([get_protos_by_pkg_name_as_fqbin/1]).
-export([gpb_version_as_string/0, gpb_version_as_list/0]).
@ -32,11 +54,11 @@
%% message types
-type 'Versions'() ::
#{packages => ['Package'()], % = 1
repository => iodata() % = 2
repository := iodata() % = 2
}.
-type 'Package'() ::
#{name => iodata(), % = 1
#{name := iodata(), % = 1
versions => [iodata()], % = 2
retired => [integer()] % = 3, 32 bits
}.
@ -53,18 +75,18 @@ encode_msg(Msg, MsgName, Opts) ->
TrUserData = proplists:get_value(user_data, Opts),
case MsgName of
'Versions' ->
e_msg_Versions(id(Msg, TrUserData), TrUserData);
encode_msg_Versions(id(Msg, TrUserData), TrUserData);
'Package' ->
e_msg_Package(id(Msg, TrUserData), TrUserData)
encode_msg_Package(id(Msg, TrUserData), TrUserData)
end.
e_msg_Versions(Msg, TrUserData) ->
e_msg_Versions(Msg, <<>>, TrUserData).
encode_msg_Versions(Msg, TrUserData) ->
encode_msg_Versions(Msg, <<>>, TrUserData).
e_msg_Versions(#{repository := F2} = M, Bin,
TrUserData) ->
encode_msg_Versions(#{repository := F2} = M, Bin,
TrUserData) ->
B1 = case M of
#{packages := F1} ->
TrF1 = id(F1, TrUserData),
@ -78,11 +100,12 @@ e_msg_Versions(#{repository := F2} = M, Bin,
e_type_string(TrF2, <<B1/binary, 18>>, TrUserData)
end.
e_msg_Package(Msg, TrUserData) ->
e_msg_Package(Msg, <<>>, TrUserData).
encode_msg_Package(Msg, TrUserData) ->
encode_msg_Package(Msg, <<>>, TrUserData).
e_msg_Package(#{name := F1} = M, Bin, TrUserData) ->
encode_msg_Package(#{name := F1} = M, Bin,
TrUserData) ->
B1 = begin
TrF1 = id(F1, TrUserData),
e_type_string(TrF1, <<Bin/binary, 10>>, TrUserData)
@ -105,7 +128,7 @@ e_msg_Package(#{name := F1} = M, Bin, TrUserData) ->
end.
e_mfield_Versions_packages(Msg, Bin, TrUserData) ->
SubBin = e_msg_Package(Msg, <<>>, TrUserData),
SubBin = encode_msg_Package(Msg, <<>>, TrUserData),
Bin2 = e_varint(byte_size(SubBin), Bin),
<<Bin2/binary, SubBin/binary>>.
@ -247,12 +270,6 @@ decode_msg_1_catch(Bin, MsgName, TrUserData) ->
catch Class:Reason:StackTrace -> error({gpb_error,{decoding_failure, {Bin, MsgName, {Class, Reason, StackTrace}}}})
end.
-else.
-ifdef('GPB_PATTERN_STACK').
decode_msg_1_catch(Bin, MsgName, TrUserData) ->
try decode_msg_2_doit(MsgName, Bin, TrUserData)
catch Class:Reason:StackTrace -> error({gpb_error,{decoding_failure, {Bin, MsgName, {Class, Reason, StackTrace}}}})
end.
-else.
decode_msg_1_catch(Bin, MsgName, TrUserData) ->
try decode_msg_2_doit(MsgName, Bin, TrUserData)
catch Class:Reason ->
@ -261,16 +278,14 @@ decode_msg_1_catch(Bin, MsgName, TrUserData) ->
end.
-endif.
-endif.
decode_msg_2_doit('Versions', Bin, TrUserData) ->
id(d_msg_Versions(Bin, TrUserData), TrUserData);
id(decode_msg_Versions(Bin, TrUserData), TrUserData);
decode_msg_2_doit('Package', Bin, TrUserData) ->
id(d_msg_Package(Bin, TrUserData), TrUserData).
id(decode_msg_Package(Bin, TrUserData), TrUserData).
d_msg_Versions(Bin, TrUserData) ->
decode_msg_Versions(Bin, TrUserData) ->
dfp_read_field_def_Versions(Bin, 0, 0,
id([], TrUserData), id('$undef', TrUserData),
TrUserData).
@ -343,7 +358,7 @@ d_field_Versions_packages(<<0:1, X:7, Rest/binary>>, N,
{NewFValue, RestF} = begin
Len = X bsl N + Acc,
<<Bs:Len/binary, Rest2/binary>> = Rest,
{id(d_msg_Package(Bs, TrUserData), TrUserData),
{id(decode_msg_Package(Bs, TrUserData), TrUserData),
Rest2}
end,
dfp_read_field_def_Versions(RestF, 0, 0,
@ -404,7 +419,7 @@ skip_64_Versions(<<_:64, Rest/binary>>, Z1, Z2, F@_1,
dfp_read_field_def_Versions(Rest, Z1, Z2, F@_1, F@_2,
TrUserData).
d_msg_Package(Bin, TrUserData) ->
decode_msg_Package(Bin, TrUserData) ->
dfp_read_field_def_Package(Bin, 0, 0,
id('$undef', TrUserData), id([], TrUserData),
id([], TrUserData), TrUserData).
@ -724,6 +739,7 @@ verify_msg(Msg, MsgName, Opts) ->
-compile({nowarn_unused_function,v_msg_Versions/3}).
-dialyzer({nowarn_function,v_msg_Versions/3}).
v_msg_Versions(#{repository := F2} = M, Path,
TrUserData) ->
case M of
@ -754,6 +770,7 @@ v_msg_Versions(X, Path, _TrUserData) ->
mk_type_error({expected_msg, 'Versions'}, X, Path).
-compile({nowarn_unused_function,v_msg_Package/3}).
-dialyzer({nowarn_function,v_msg_Package/3}).
v_msg_Package(#{name := F1} = M, Path, TrUserData) ->
v_type_string(F1, [name | Path], TrUserData),
case M of
@ -796,6 +813,7 @@ v_msg_Package(X, Path, _TrUserData) ->
mk_type_error({expected_msg, 'Package'}, X, Path).
-compile({nowarn_unused_function,v_type_int32/3}).
-dialyzer({nowarn_function,v_type_int32/3}).
v_type_int32(N, _Path, _TrUserData)
when -2147483648 =< N, N =< 2147483647 ->
ok;
@ -807,6 +825,7 @@ v_type_int32(X, Path, _TrUserData) ->
Path).
-compile({nowarn_unused_function,v_type_string/3}).
-dialyzer({nowarn_function,v_type_string/3}).
v_type_string(S, Path, _TrUserData)
when is_list(S); is_binary(S) ->
try unicode:characters_to_binary(S) of
@ -829,11 +848,12 @@ mk_type_error(Error, ValueSeen, Path) ->
-compile({nowarn_unused_function,prettify_path/1}).
-dialyzer({nowarn_function,prettify_path/1}).
prettify_path([]) -> top_level;
prettify_path(PathR) ->
list_to_atom(string:join(lists:map(fun atom_to_list/1,
lists:reverse(PathR)),
".")).
list_to_atom(lists:append(lists:join(".",
lists:map(fun atom_to_list/1,
lists:reverse(PathR))))).
-compile({nowarn_unused_function,id/2}).
@ -859,6 +879,7 @@ cons(Elem, Acc, _TrUserData) -> [Elem | Acc].
-compile({inline,'erlang_++'/3}).
'erlang_++'(A, B, _TrUserData) -> A ++ B.
get_msg_defs() ->
[{{msg, 'Versions'},
[#{name => packages, fnum => 1, rnum => 2,
@ -947,12 +968,135 @@ fetch_rpc_def(ServiceName, RpcName) ->
erlang:error({no_such_rpc, ServiceName, RpcName}).
%% Convert a a fully qualified (ie with package name) service name
%% as a binary to a service name as an atom.
-spec fqbin_to_service_name(_) -> no_return().
fqbin_to_service_name(X) ->
error({gpb_error, {badservice, X}}).
%% Convert a service name as an atom to a fully qualified
%% (ie with package name) name as a binary.
-spec service_name_to_fqbin(_) -> no_return().
service_name_to_fqbin(X) ->
error({gpb_error, {badservice, X}}).
%% Convert a a fully qualified (ie with package name) service name
%% and an rpc name, both as binaries to a service name and an rpc
%% name, as atoms.
-spec fqbins_to_service_and_rpc_name(_, _) -> no_return().
fqbins_to_service_and_rpc_name(S, R) ->
error({gpb_error, {badservice_or_rpc, {S, R}}}).
%% Convert a service name and an rpc name, both as atoms,
%% to a fully qualified (ie with package name) service name and
%% an rpc name as binaries.
-spec service_and_rpc_name_to_fqbins(_, _) -> no_return().
service_and_rpc_name_to_fqbins(S, R) ->
error({gpb_error, {badservice_or_rpc, {S, R}}}).
fqbin_to_msg_name(<<"Versions">>) -> 'Versions';
fqbin_to_msg_name(<<"Package">>) -> 'Package';
fqbin_to_msg_name(E) -> error({gpb_error, {badmsg, E}}).
msg_name_to_fqbin('Versions') -> <<"Versions">>;
msg_name_to_fqbin('Package') -> <<"Package">>;
msg_name_to_fqbin(E) -> error({gpb_error, {badmsg, E}}).
-spec fqbin_to_enum_name(_) -> no_return().
fqbin_to_enum_name(E) ->
error({gpb_error, {badenum, E}}).
-spec enum_name_to_fqbin(_) -> no_return().
enum_name_to_fqbin(E) ->
error({gpb_error, {badenum, E}}).
get_package_name() -> undefined.
%% Whether or not the message names
%% are prepended with package name or not.
uses_packages() -> false.
source_basename() -> "r3_hex_pb_versions.proto".
%% Retrieve all proto file names, also imported ones.
%% The order is top-down. The first element is always the main
%% source file. The files are returned with extension,
%% see get_all_proto_names/0 for a version that returns
%% the basenames sans extension
get_all_source_basenames() -> ["r3_hex_pb_versions.proto"].
%% Retrieve all proto file names, also imported ones.
%% The order is top-down. The first element is always the main
%% source file. The files are returned sans .proto extension,
%% to make it easier to use them with the various get_xyz_containment
%% functions.
get_all_proto_names() -> ["r3_hex_pb_versions"].
get_msg_containment("r3_hex_pb_versions") ->
['Package', 'Versions'];
get_msg_containment(P) ->
error({gpb_error, {badproto, P}}).
get_pkg_containment("r3_hex_pb_versions") -> undefined;
get_pkg_containment(P) ->
error({gpb_error, {badproto, P}}).
get_service_containment("r3_hex_pb_versions") -> [];
get_service_containment(P) ->
error({gpb_error, {badproto, P}}).
get_rpc_containment("r3_hex_pb_versions") -> [];
get_rpc_containment(P) ->
error({gpb_error, {badproto, P}}).
get_enum_containment("r3_hex_pb_versions") -> [];
get_enum_containment(P) ->
error({gpb_error, {badproto, P}}).
get_proto_by_msg_name_as_fqbin(<<"Versions">>) ->
"r3_hex_pb_versions";
get_proto_by_msg_name_as_fqbin(<<"Package">>) ->
"r3_hex_pb_versions";
get_proto_by_msg_name_as_fqbin(E) ->
error({gpb_error, {badmsg, E}}).
-spec get_proto_by_service_name_as_fqbin(_) -> no_return().
get_proto_by_service_name_as_fqbin(E) ->
error({gpb_error, {badservice, E}}).
-spec get_proto_by_enum_name_as_fqbin(_) -> no_return().
get_proto_by_enum_name_as_fqbin(E) ->
error({gpb_error, {badenum, E}}).
-spec get_protos_by_pkg_name_as_fqbin(_) -> no_return().
get_protos_by_pkg_name_as_fqbin(E) ->
error({gpb_error, {badpkg, E}}).
gpb_version_as_string() ->
"4.3.1".
"4.10.0".
gpb_version_as_list() ->
[4,3,1].
[4,10,0].

+ 3
- 3
src/vendored/r3_hex_registry.erl 查看文件

@ -1,4 +1,4 @@
%% Vendored from hex_core v0.7.0, do not edit manually
%% Vendored from hex_core v0.7.1, do not edit manually
-module(r3_hex_registry).
-export([
@ -16,8 +16,8 @@
]).
-include_lib("public_key/include/public_key.hrl").
-type private_key() :: public_key:rsa_private_key() | binary().
-type public_key() :: public_key:rsa_public_key() | binary().
-type private_key() :: #'RSAPrivateKey'{} | binary().
-type public_key() :: #'RSAPublicKey'{} | binary().
%%====================================================================
%% API functions

+ 2
- 2
src/vendored/r3_hex_repo.erl 查看文件

@ -1,4 +1,4 @@
%% Vendored from hex_core v0.7.0, do not edit manually
%% Vendored from hex_core v0.7.1, do not edit manually
-module(r3_hex_repo).
-export([
@ -94,7 +94,7 @@ get_package(Config, Name) when is_binary(Name) and is_map(Config) ->
%% Examples:
%%
%% ```
%% > {ok, {200, _, Tarball}} = r3_hex_repo:get_tarball(<<"package1">>, <<"1.0.0">>, r3_hex_core:default_config()),
%% > {ok, {200, _, Tarball}} = r3_hex_repo:get_tarball(r3_hex_core:default_config(), <<"package1">>, <<"1.0.0">>),
%% > {ok, #{metadata := Metadata}} = r3_hex_tarball:unpack(Tarball, memory).
%% '''
%% @end

+ 2
- 2
src/vendored/r3_hex_tarball.erl 查看文件

@ -1,4 +1,4 @@
%% Vendored from hex_core v0.7.0, do not edit manually
%% Vendored from hex_core v0.7.1, do not edit manually
-module(r3_hex_tarball).
-export([create/2, create/3, create_docs/1, create_docs/2, unpack/2, unpack/3,
@ -31,7 +31,7 @@
%% Creates a package tarball.
%%
%% Returns the binary of the tarball the "inner checksum" and "outer checksum".
%% The inner checksum is deprecated in favor of the inner checksum.
%% The inner checksum is deprecated in favor of the outer checksum.
%%
%% Examples:
%%

+ 1
- 1
src/vendored/r3_safe_erl_term.xrl 查看文件

@ -1,4 +1,4 @@
%% Vendored from hex_core v0.7.0, do not edit manually
%% Vendored from hex_core v0.7.1, do not edit manually
%%% Author : Robert Virding
%%% Purpose : Token definitions for Erlang.

+ 9
- 9
test/rebar_pkg_repos_SUITE.erl 查看文件

@ -382,14 +382,14 @@ use_first_repo_match(Config) ->
?assertMatch({ok,{package,{<<"B">>, {{2,0,0}, {[],[]}}, Repo2},
<<"inner checksum">>,<<"outer checksum">>, false, []},
#{name := Repo2,
http_adapter_config := #{profile := rebar}}},
http_adapter := {r3_hex_http_httpc, #{profile := rebar}}}},
rebar_packages:resolve_version(<<"B">>, <<"> 1.4.0">>, undefined, undefined,
?PACKAGE_TABLE, State)),
?assertMatch({ok,{package,{<<"B">>, {{1,4,0}, {[],[]}}, Repo3},
<<"inner checksum">>,<<"outer checksum">>, false, []},
#{name := Repo3,
http_adapter_config := #{profile := rebar}}},
http_adapter := {r3_hex_http_httpc, #{profile := rebar}}}},
rebar_packages:resolve_version(<<"B">>, <<"~> 1.4.0">>, undefined, undefined,
?PACKAGE_TABLE, State)).
@ -400,7 +400,7 @@ use_exact_with_hash(Config) ->
?assertMatch({ok,{package,{<<"C">>, {{1,3,1}, {[],[]}}, Repo2},
<<"inner checksum">>, <<"good outer checksum">>, false, []},
#{name := Repo2,
http_adapter_config := #{profile := rebar}}},
http_adapter := {r3_hex_http_httpc, #{profile := rebar}}}},
rebar_packages:resolve_version(<<"C">>, <<"1.3.1">>, <<"inner checksum">>, <<"good outer checksum">>,
?PACKAGE_TABLE, State)).
@ -410,7 +410,7 @@ fail_repo_update(Config) ->
?assertMatch({ok,{package,{<<"B">>, {{1,4,0}, {[],[]}}, Repo3},
<<"inner checksum">>,<<"outer checksum">>, false, []},
#{name := Repo3,
http_adapter_config := #{profile := rebar}}},
http_adapter := {r3_hex_http_httpc, #{profile := rebar}}}},
rebar_packages:resolve_version(<<"B">>, <<"~> 1.4.0">>, undefined, undefined,
?PACKAGE_TABLE, State)).
@ -421,7 +421,7 @@ ignore_match_in_excluded_repo(Config) ->
?assertMatch({ok,{package,{<<"B">>, {{1,4,6}, {[],[]}}, Hexpm},
<<"inner checksum">>,<<"outer checksum">>, #{reason := 'RETIRED_INVALID'}, []},
#{name := Hexpm,
http_adapter_config := #{profile := rebar}}},
http_adapter := {r3_hex_http_httpc, #{profile := rebar}}}},
rebar_packages:resolve_version(<<"B">>, <<"~> 1.4.0">>, undefined, undefined,
?PACKAGE_TABLE, State)),
@ -429,7 +429,7 @@ ignore_match_in_excluded_repo(Config) ->
?assertMatch({ok,{package,{<<"A">>, {{0,1,1}, {[],[]}}, Repo2},
<<"inner checksum">>, <<"good outer checksum">>, false, []},
#{name := Repo2,
http_adapter_config := #{profile := rebar}}},
http_adapter := {r3_hex_http_httpc, #{profile := rebar}}}},
rebar_packages:resolve_version(<<"A">>, <<"0.1.1">>, <<"inner checksum">>, <<"good outer checksum">>,
?PACKAGE_TABLE, State)).
@ -439,14 +439,14 @@ optional_prereleases(Config) ->
?assertMatch({ok,{package,{<<"B">>, {{1,5,0}, {[],[]}}, Hexpm},
<<"inner checksum">>,<<"outer checksum">>, false, []},
#{name := Hexpm,
http_adapter_config := #{profile := rebar}}},
http_adapter := {r3_hex_http_httpc, #{profile := rebar}}}},
rebar_packages:resolve_version(<<"B">>, <<"~> 1.5.0">>, undefined, undefined,
?PACKAGE_TABLE, State)),
?assertMatch({ok,{package,{<<"B">>, {{1,5,6}, {[<<"rc">>,0],[]}}, Hexpm},
<<"inner checksum">>,<<"outer checksum">>, true, []},
#{name := Hexpm,
http_adapter_config := #{profile := rebar}}},
http_adapter := {r3_hex_http_httpc, #{profile := rebar}}}},
rebar_packages:resolve_version(<<"B">>, <<"1.5.6-rc.0">>, <<"inner checksum">>, <<"outer checksum">>,
?PACKAGE_TABLE, State)),
@ -455,7 +455,7 @@ optional_prereleases(Config) ->
?assertMatch({ok,{package,{<<"B">>, {{1,5,6}, {[<<"rc">>,0],[]}}, Hexpm},
<<"inner checksum">>,<<"outer checksum">>, true, []},
#{name := Hexpm,
http_adapter_config := #{profile := rebar}}},
http_adapter := {r3_hex_http_httpc, #{profile := rebar}}}},
rebar_packages:resolve_version(<<"B">>, <<"~> 1.5.0">>, <<"inner checksum">>, <<"outer checksum">>,
?PACKAGE_TABLE, State1)).

+ 10
- 58
vendor_hex_core.sh 查看文件

@ -6,61 +6,13 @@ if [[ -z "$1" ]]; then
exit 1
fi
source_dir=$1/src
target_dir=src/vendored
prefix=r3_
hex_core_version=`cat $source_dir/hex_core.hrl | grep HEX_CORE_VERSION | cut -d'"' -f2`
filenames="hex_core.hrl \
hex_core.erl \
hex_erl_tar.erl \
hex_erl_tar.hrl \
hex_filename.erl \
hex_pb_names.erl \
hex_pb_package.erl \
hex_pb_signed.erl \
hex_pb_versions.erl \
hex_tarball.erl \
hex_registry.erl \
hex_http_httpc.erl \
hex_http.erl \
hex_repo.erl \
hex_api.erl \
hex_api_key.erl \
hex_api_package.erl \
hex_api_package_owner.erl \
hex_api_release.erl \
hex_api_user.erl \
safe_erl_term.xrl"
search_to_replace="hex_core: \
hex_core) \
hex_core.hrl \
hex_erl_tar \
hex_filename \
hex_pb_names \
hex_pb_package \
hex_pb_signed \
hex_pb_versions \
hex_registry \
hex_tarball \
hex_http \
hex_repo \
hex_api \
safe_erl_term"
rm -f $target_dir/$prefix*
for filename in $filenames; do
source_path=$source_dir/$filename
target_path=$target_dir/$prefix$filename
echo "%% Vendored from hex_core v$hex_core_version, do not edit manually" > $target_path
echo >> $target_path
cat $source_path >> $target_path
for word in $search_to_replace; do
sed -i.bak s/$word/$prefix$word/g $target_path
rm $target_path.bak
done
done
REBAR3_TOP=$(pwd)
export REBAR3_TOP
pushd "$1"
touch proto/* # force re-generation of protobuf elements
TARGET_ERLANG_VERSION=19
export TARGET_ERLANG_VERSION
rebar3 as dev compile
./vendor.sh src r3_
find src -regex '.*r3_.*' -exec mv -f {} "$REBAR3_TOP/src/vendored" \;
popd

Loading…
取消
儲存