From 1ebde42996d5077b31be23f04c1cca23f8a4656a Mon Sep 17 00:00:00 2001 From: "Paulo F. Oliveira" Date: Wed, 28 Oct 2020 21:32:06 +0000 Subject: [PATCH 01/17] Prevent warnings on unknown functions/types --- rebar.config | 3 ++- src/rebar_compiler.erl | 10 +++++----- src/rebar_file_utils.erl | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/rebar.config b/rebar.config index 8a655ade..9766d23b 100644 --- a/rebar.config +++ b/rebar.config @@ -46,7 +46,8 @@ %% Use OTP 18+ when dialyzing rebar3 {dialyzer, [ {warnings, [unknown]}, - {exclude_mods, [rebar_prv_alias]} + {exclude_mods, [rebar_prv_alias]}, + {plt_extra_apps, [parsetools, public_key]} ]}. %% Keep only the logs of the last 5 runs diff --git a/src/rebar_compiler.erl b/src/rebar_compiler.erl index 29dc6510..f24b0606 100644 --- a/src/rebar_compiler.erl +++ b/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), diff --git a/src/rebar_file_utils.erl b/src/rebar_file_utils.erl index df4d1b5a..425f4c52 100644 --- a/src/rebar_file_utils.erl +++ b/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")). From b63f9cdc779c24664c5a192b79e036adf6bbb8ed Mon Sep 17 00:00:00 2001 From: "Paulo F. Oliveira" Date: Wed, 28 Oct 2020 22:07:04 +0000 Subject: [PATCH 02/17] Target our analysis scope --- rebar.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rebar.config b/rebar.config index 9766d23b..ae3a067e 100644 --- a/rebar.config +++ b/rebar.config @@ -43,7 +43,7 @@ {edoc_opts, [preprocess]}. -%% Use OTP 18+ when dialyzing rebar3 +%% Use OTP 23+ when dialyzing rebar3 {dialyzer, [ {warnings, [unknown]}, {exclude_mods, [rebar_prv_alias]}, From 4cf78dc1030933a4daf6c5bf063fb1b20a8a9a5b Mon Sep 17 00:00:00 2001 From: "Paulo F. Oliveira" Date: Wed, 28 Oct 2020 22:07:11 +0000 Subject: [PATCH 03/17] Broaden our analysis scope --- rebar.config | 1 - 1 file changed, 1 deletion(-) diff --git a/rebar.config b/rebar.config index ae3a067e..e2ff5d27 100644 --- a/rebar.config +++ b/rebar.config @@ -46,7 +46,6 @@ %% Use OTP 23+ when dialyzing rebar3 {dialyzer, [ {warnings, [unknown]}, - {exclude_mods, [rebar_prv_alias]}, {plt_extra_apps, [parsetools, public_key]} ]}. From 44ffb45f17d960d305175c610f02b848b597369e Mon Sep 17 00:00:00 2001 From: "Paulo F. Oliveira" Date: Wed, 28 Oct 2020 22:10:19 +0000 Subject: [PATCH 04/17] Prevent warnings on wrongly -spec.(_)'ed types (some are not "wrong" per se, but incomplete) --- src/rebar.hrl | 6 +++--- src/rebar_api.erl | 2 +- src/rebar_app_info.erl | 22 +++++++++++----------- src/rebar_app_utils.erl | 10 ++++++---- src/rebar_paths.erl | 2 +- src/rebar_pkg_resource.erl | 7 ++++--- src/rebar_resource_v2.erl | 3 ++- src/rebar_utils.erl | 4 ++-- 8 files changed, 30 insertions(+), 26 deletions(-) diff --git a/src/rebar.hrl b/src/rebar.hrl index 73a2c20f..39ae900a 100644 --- a/src/rebar.hrl +++ b/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()}). diff --git a/src/rebar_api.erl b/src/rebar_api.erl index cbb4b699..373e65fb 100644 --- a/src/rebar_api.erl +++ b/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). diff --git a/src/rebar_app_info.erl b/src/rebar_app_info.erl index 47efbfda..bc983bc1 100644 --- a/src/rebar_app_info.erl +++ b/src/rebar_app_info.erl @@ -87,9 +87,9 @@ 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, - parent=root :: binary() | root, + original_vsn :: binary() | string() | undefined, + vsn :: binary() | string() | undefined, + parent=root :: binary() | root | string(), app_details=[] :: list(), applications=[] :: list(), included_applications=[] :: [atom()], @@ -177,13 +177,13 @@ new(Parent, AppName, Vsn, Dir, Deps) -> deps=Deps}}. -spec app_to_map(t()) -> #{name := atom(), - vsn := string(), + vsn := binary() | string(), 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, @@ -414,18 +414,18 @@ app_details(AppInfo=#app_info_t{}, AppDetails) -> AppInfo#app_info_t{app_details=AppDetails}. %% @doc returns the app's parent in the dep tree. --spec parent(t()) -> root | binary(). +-spec parent(t()) -> root | binary() | string(). parent(#app_info_t{parent=Parent}) -> Parent. %% @doc sets the app's parent. --spec parent(t(), binary() | root) -> t(). +-spec parent(t(), binary() | root | string()) -> t(). parent(AppInfo=#app_info_t{}, Parent) -> AppInfo#app_info_t{parent=Parent}. %% @doc returns the original version of the app (unevaluated if %% asking for a semver) --spec original_vsn(t()) -> binary(). +-spec original_vsn(t()) -> binary() | string(). original_vsn(#app_info_t{original_vsn=Vsn}) -> Vsn. @@ -436,7 +436,7 @@ 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()) -> binary() | string(). vsn(#app_info_t{vsn=Vsn}) -> Vsn. @@ -505,7 +505,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 +559,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}. diff --git a/src/rebar_app_utils.erl b/src/rebar_app_utils.erl index ee39f541..64a40c46 100644 --- a/src/rebar_app_utils.erl +++ b/src/rebar_app_utils.erl @@ -171,7 +171,7 @@ parse_deps(Parent, DepsDir, Deps, State, Locks, Level) -> %% (if it is a newer thing) or from the locks specified in the lockfile. -spec parse_dep(Dep, Parent, Dir, State, Locks, Level) -> rebar_app_info:t() when Dep :: tuple() | atom() | binary(), % TODO: meta to source() | lock() - Parent :: root | binary(), + Parent :: root | binary() | string(), Dir :: file:filename(), State :: rebar_state:t(), Locks :: [tuple()], % TODO: meta to [lock()] @@ -199,7 +199,7 @@ parse_dep(Dep, Parent, DepsDir, State, Locks, Level) -> %% @doc converts a dependency definition and a location for it on disk %% into an app info tuple representing it. -spec parse_dep(Parent, Dep, Dir, IsLock, State) -> rebar_app_info:t() when - Parent :: root | binary(), + Parent :: root | binary() | string(), Dep :: tuple() | atom() | binary(), % TODO: meta to source() | lock() Dir :: file:filename(), IsLock :: boolean(), @@ -244,7 +244,7 @@ parse_dep(_, Dep, _, _, _) -> %% @doc convert a dependency that has just been fetched into %% an app info record related to it -spec dep_to_app(Parent, Dir, Name, Vsn, Source, IsLock, State) -> rebar_app_info:t() when - Parent :: root | binary(), + Parent :: root | binary() | string(), Dir :: file:filename(), Name :: binary(), Vsn :: iodata() | undefined, @@ -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) -> diff --git a/src/rebar_paths.erl b/src/rebar_paths.erl index 7a494430..d2bc59d3 100644 --- a/src/rebar_paths.erl +++ b/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]). diff --git a/src/rebar_pkg_resource.erl b/src/rebar_pkg_resource.erl index b5eecbb4..91c82a1c 100644 --- a/src/rebar_pkg_resource.erl +++ b/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 @@ -43,7 +43,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 +209,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), diff --git a/src/rebar_resource_v2.erl b/src/rebar_resource_v2.erl index 4a80f069..5dcd4ce3 100644 --- a/src/rebar_resource_v2.erl +++ b/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(). diff --git a/src/rebar_utils.erl b/src/rebar_utils.erl index cecb399e..efb9ef43 100644 --- a/src/rebar_utils.erl +++ b/src/rebar_utils.erl @@ -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 From e28af4c5368e638d30c281c8af6c32da8c85d462 Mon Sep 17 00:00:00 2001 From: "Paulo F. Oliveira" Date: Wed, 28 Oct 2020 23:33:34 +0000 Subject: [PATCH 05/17] Prevent warnings on messing with opaque elements --- src/rebar_compiler_dag.erl | 3 +++ src/rebar_prv_alias.erl | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/rebar_compiler_dag.erl b/src/rebar_compiler_dag.erl index d6038e83..ee46d5a7 100644 --- a/src/rebar_compiler_dag.erl +++ b/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, diff --git a/src/rebar_prv_alias.erl b/src/rebar_prv_alias.erl index ce56f29f..c9a8943b 100644 --- a/src/rebar_prv_alias.erl +++ b/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), ","). From 726711ab95341ef090493483a596a561930915be Mon Sep 17 00:00:00 2001 From: "Paulo F. Oliveira" Date: Wed, 28 Oct 2020 23:42:11 +0000 Subject: [PATCH 06/17] Prevent warnings on unused/unhandled code paths --- src/rebar_git_resource.erl | 4 ++-- src/rebar_uri.erl | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/rebar_git_resource.erl b/src/rebar_git_resource.erl index 7a127444..d95fd597 100644 --- a/src/rebar_git_resource.erl +++ b/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. diff --git a/src/rebar_uri.erl b/src/rebar_uri.erl index a52f0e02..428e4870 100644 --- a/src/rebar_uri.erl +++ b/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), From b44959ede49e13aa547938f8a4f5c993af137c25 Mon Sep 17 00:00:00 2001 From: "Paulo F. Oliveira" Date: Thu, 29 Oct 2020 01:00:18 +0000 Subject: [PATCH 07/17] Prevent warnings on seemingly dead code --- src/rebar_git_resource.erl | 24 +----------------------- src/rebar_paths.erl | 6 +----- 2 files changed, 2 insertions(+), 28 deletions(-) diff --git a/src/rebar_git_resource.erl b/src/rebar_git_resource.erl index d95fd597..d974d5dc 100644 --- a/src/rebar_git_resource.erl +++ b/src/rebar_git_resource.erl @@ -253,16 +253,7 @@ git_vsn_fetch() -> make_vsn(AppInfo, _) -> Dir = rebar_app_info:dir(AppInfo), - case rebar_app_info:original_vsn(AppInfo) of - {git, short} -> - git_ref(Dir, "--short"); - {git, long} -> - git_ref(Dir, ""); - _ -> - %% already parsed in rebar_utils to get here so we know it - %% is either for git or "git" - make_vsn_(Dir) - end. + make_vsn_(Dir). make_vsn_(Dir) -> case collect_default_refcount(Dir) of @@ -274,19 +265,6 @@ make_vsn_(Dir) -> %% Internal functions -git_ref(Dir, Arg) -> - case rebar_utils:sh("git rev-parse " ++ Arg ++ " HEAD", - [{use_stdout, false}, - return_on_error, - {cd, Dir}]) of - {error, _} -> - ?WARN("Getting ref of git repo failed in ~ts. " - "Falling back to version 0", [Dir]), - {plain, "0"}; - {ok, String} -> - {plain, rebar_string:trim(String, both, "\n")} - end. - collect_default_refcount(Dir) -> %% Get the tag timestamp and minimal ref from the system. The %% timestamp is really important from an ordering perspective. diff --git a/src/rebar_paths.erl b/src/rebar_paths.erl index d2bc59d3..ed3f13ce 100644 --- a/src/rebar_paths.erl +++ b/src/rebar_paths.erl @@ -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) -> From def5cc60df09279ad2cd2facceb0e80eb0a9e30b Mon Sep 17 00:00:00 2001 From: "Paulo F. Oliveira" Date: Thu, 29 Oct 2020 01:00:43 +0000 Subject: [PATCH 08/17] Tentatively fix code based on static analysis results --- src/rebar_packages.erl | 3 ++- src/rebar_utils.erl | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/rebar_packages.erl b/src/rebar_packages.erl index c3bbeaf1..a8a4d679 100644 --- a/src/rebar_packages.erl +++ b/src/rebar_packages.erl @@ -243,7 +243,8 @@ parse_checksum(Checksum) -> update_package(Name, RepoConfig=#{name := Repo}, State) -> ?MODULE:verify_table(State), - try r3_hex_repo:get_package(get_package_repo_config(RepoConfig), Name) of + PkgRepoConfig1 = get_package_repo_config(RepoConfig), + try r3_hex_repo:get_package(maps:remove(name, PkgRepoConfig1#{repo_name := Repo}), Name) of {ok, {200, _Headers, Releases}} -> _ = insert_releases(Name, Releases, Repo, ?PACKAGE_TABLE), {ok, RegistryDir} = rebar_packages:registry_dir(State), diff --git a/src/rebar_utils.erl b/src/rebar_utils.erl index efb9ef43..ecd31215 100644 --- a/src/rebar_utils.erl +++ b/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, From 8604b0c3b15a8b728599ce7ba33864f03b5f067c Mon Sep 17 00:00:00 2001 From: "Paulo F. Oliveira" Date: Fri, 30 Oct 2020 00:46:47 +0000 Subject: [PATCH 09/17] Silence warnings we're OK with --- src/rebar_state.erl | 1 + 1 file changed, 1 insertion(+) diff --git a/src/rebar_state.erl b/src/rebar_state.erl index 4d2c2631..c8b3c8ae 100644 --- a/src/rebar_state.erl +++ b/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) -> From e80c3c874da600ed52065dec95ab1a80169cb40a Mon Sep 17 00:00:00 2001 From: "Paulo F. Oliveira" Date: Wed, 4 Nov 2020 23:14:00 +0000 Subject: [PATCH 10/17] Simplify script 1. we now rely on $1's vendor.sh script (instead of duplicating it here) 2. we assume that hex_core is rebar3-compatible 3. we rely on TARGET_ERLANG_VERSION 4. we generate exactly what was previously generating, while targeting a specific Erlang/OTP vsn --- vendor_hex_core.sh | 68 +++++++--------------------------------------- 1 file changed, 10 insertions(+), 58 deletions(-) diff --git a/vendor_hex_core.sh b/vendor_hex_core.sh index fe78b677..7c4892e2 100755 --- a/vendor_hex_core.sh +++ b/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" \; +popd From 61f7e4784f71b07a8c1f1495ac7237bc29a38d0f Mon Sep 17 00:00:00 2001 From: "Paulo F. Oliveira" Date: Fri, 6 Nov 2020 15:09:46 +0000 Subject: [PATCH 11/17] Broaden expected typespec --- src/rebar_app_info.erl | 23 ++++++++++++----------- src/rebar_git_resource.erl | 24 +++++++++++++++++++++++- 2 files changed, 35 insertions(+), 12 deletions(-) diff --git a/src/rebar_app_info.erl b/src/rebar_app_info.erl index bc983bc1..15b9701d 100644 --- a/src/rebar_app_info.erl +++ b/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() | string() | undefined, - vsn :: binary() | string() | undefined, + original_vsn :: app_vsn() | undefined, + vsn :: app_vsn() | undefined, parent=root :: binary() | root | string(), 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,7 +178,7 @@ new(Parent, AppName, Vsn, Dir, Deps) -> deps=Deps}}. -spec app_to_map(t()) -> #{name := atom(), - vsn := binary() | string(), + vsn := app_vsn(), applications := [atom()], included_applications := [atom()], dir := file:name(), @@ -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() | string(). +-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() | string(). +-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}. diff --git a/src/rebar_git_resource.erl b/src/rebar_git_resource.erl index d974d5dc..d95fd597 100644 --- a/src/rebar_git_resource.erl +++ b/src/rebar_git_resource.erl @@ -253,7 +253,16 @@ git_vsn_fetch() -> make_vsn(AppInfo, _) -> Dir = rebar_app_info:dir(AppInfo), - make_vsn_(Dir). + case rebar_app_info:original_vsn(AppInfo) of + {git, short} -> + git_ref(Dir, "--short"); + {git, long} -> + git_ref(Dir, ""); + _ -> + %% already parsed in rebar_utils to get here so we know it + %% is either for git or "git" + make_vsn_(Dir) + end. make_vsn_(Dir) -> case collect_default_refcount(Dir) of @@ -265,6 +274,19 @@ make_vsn_(Dir) -> %% Internal functions +git_ref(Dir, Arg) -> + case rebar_utils:sh("git rev-parse " ++ Arg ++ " HEAD", + [{use_stdout, false}, + return_on_error, + {cd, Dir}]) of + {error, _} -> + ?WARN("Getting ref of git repo failed in ~ts. " + "Falling back to version 0", [Dir]), + {plain, "0"}; + {ok, String} -> + {plain, rebar_string:trim(String, both, "\n")} + end. + collect_default_refcount(Dir) -> %% Get the tag timestamp and minimal ref from the system. The %% timestamp is really important from an ordering perspective. From dc7882a86961533940bc2703fa901d054e6effbf Mon Sep 17 00:00:00 2001 From: "Paulo F. Oliveira" Date: Fri, 6 Nov 2020 15:20:15 +0000 Subject: [PATCH 12/17] Revert to previous typespec while adapting calls to it --- src/rebar_app_info.erl | 6 +++--- src/rebar_app_utils.erl | 6 +++--- src/rebar_prv_plugins_upgrade.erl | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/rebar_app_info.erl b/src/rebar_app_info.erl index 15b9701d..9b6fba42 100644 --- a/src/rebar_app_info.erl +++ b/src/rebar_app_info.erl @@ -90,7 +90,7 @@ app_file :: file:filename_all() | undefined, original_vsn :: app_vsn() | undefined, vsn :: app_vsn() | undefined, - parent=root :: binary() | root | string(), + parent=root :: binary() | root, app_details=[] :: list(), applications=[] :: list(), included_applications=[] :: [atom()], @@ -415,12 +415,12 @@ app_details(AppInfo=#app_info_t{}, AppDetails) -> AppInfo#app_info_t{app_details=AppDetails}. %% @doc returns the app's parent in the dep tree. --spec parent(t()) -> root | binary() | string(). +-spec parent(t()) -> root | binary(). parent(#app_info_t{parent=Parent}) -> Parent. %% @doc sets the app's parent. --spec parent(t(), binary() | root | string()) -> t(). +-spec parent(t(), binary() | root) -> t(). parent(AppInfo=#app_info_t{}, Parent) -> AppInfo#app_info_t{parent=Parent}. diff --git a/src/rebar_app_utils.erl b/src/rebar_app_utils.erl index 64a40c46..4786101f 100644 --- a/src/rebar_app_utils.erl +++ b/src/rebar_app_utils.erl @@ -171,7 +171,7 @@ parse_deps(Parent, DepsDir, Deps, State, Locks, Level) -> %% (if it is a newer thing) or from the locks specified in the lockfile. -spec parse_dep(Dep, Parent, Dir, State, Locks, Level) -> rebar_app_info:t() when Dep :: tuple() | atom() | binary(), % TODO: meta to source() | lock() - Parent :: root | binary() | string(), + Parent :: root | binary(), Dir :: file:filename(), State :: rebar_state:t(), Locks :: [tuple()], % TODO: meta to [lock()] @@ -199,7 +199,7 @@ parse_dep(Dep, Parent, DepsDir, State, Locks, Level) -> %% @doc converts a dependency definition and a location for it on disk %% into an app info tuple representing it. -spec parse_dep(Parent, Dep, Dir, IsLock, State) -> rebar_app_info:t() when - Parent :: root | binary() | string(), + Parent :: root | binary(), Dep :: tuple() | atom() | binary(), % TODO: meta to source() | lock() Dir :: file:filename(), IsLock :: boolean(), @@ -244,7 +244,7 @@ parse_dep(_, Dep, _, _, _) -> %% @doc convert a dependency that has just been fetched into %% an app info record related to it -spec dep_to_app(Parent, Dir, Name, Vsn, Source, IsLock, State) -> rebar_app_info:t() when - Parent :: root | binary() | string(), + Parent :: root | binary(), Dir :: file:filename(), Name :: binary(), Vsn :: iodata() | undefined, diff --git a/src/rebar_prv_plugins_upgrade.erl b/src/rebar_prv_plugins_upgrade.erl index c62876c7..3ad3dc72 100644 --- a/src/rebar_prv_plugins_upgrade.erl +++ b/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 From e7b02620d86eded40e7e99733f9b072715dd16f1 Mon Sep 17 00:00:00 2001 From: "Paulo F. Oliveira" Date: Fri, 6 Nov 2020 23:41:03 +0000 Subject: [PATCH 13/17] Simplify our approach --- src/rebar_packages.erl | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/rebar_packages.erl b/src/rebar_packages.erl index a8a4d679..1f403da3 100644 --- a/src/rebar_packages.erl +++ b/src/rebar_packages.erl @@ -243,8 +243,7 @@ parse_checksum(Checksum) -> update_package(Name, RepoConfig=#{name := Repo}, State) -> ?MODULE:verify_table(State), - PkgRepoConfig1 = get_package_repo_config(RepoConfig), - try r3_hex_repo:get_package(maps:remove(name, PkgRepoConfig1#{repo_name := Repo}), Name) of + try r3_hex_repo:get_package(get_package_repo_config(RepoConfig), Name) of {ok, {200, _Headers, Releases}} -> _ = insert_releases(Name, Releases, Repo, ?PACKAGE_TABLE), {ok, RegistryDir} = rebar_packages:registry_dir(State), @@ -268,8 +267,8 @@ 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) -> RepoConfig. From cff6bbdff801bd2dfec66cd87fc61a5f81badb82 Mon Sep 17 00:00:00 2001 From: "Paulo F. Oliveira" Date: Tue, 17 Nov 2020 21:56:56 +0000 Subject: [PATCH 14/17] Re-vendor hex_core to 0.7.1 --- src/vendored/r3_hex_api.erl | 2 +- src/vendored/r3_hex_api_key.erl | 2 +- src/vendored/r3_hex_api_package.erl | 2 +- src/vendored/r3_hex_api_package_owner.erl | 2 +- src/vendored/r3_hex_api_release.erl | 4 +- src/vendored/r3_hex_api_user.erl | 2 +- src/vendored/r3_hex_core.erl | 13 +- src/vendored/r3_hex_core.hrl | 4 +- src/vendored/r3_hex_erl_tar.erl | 2 +- src/vendored/r3_hex_erl_tar.hrl | 2 +- src/vendored/r3_hex_filename.erl | 2 +- src/vendored/r3_hex_http.erl | 16 +- src/vendored/r3_hex_http_httpc.erl | 2 +- src/vendored/r3_hex_pb_names.erl | 206 +++++-- src/vendored/r3_hex_pb_package.erl | 647 ++++++++++++++++------ src/vendored/r3_hex_pb_signed.erl | 183 +++++- src/vendored/r3_hex_pb_versions.erl | 208 +++++-- src/vendored/r3_hex_registry.erl | 6 +- src/vendored/r3_hex_repo.erl | 4 +- src/vendored/r3_hex_tarball.erl | 4 +- src/vendored/r3_safe_erl_term.xrl | 2 +- vendor_hex_core.sh | 2 +- 22 files changed, 1025 insertions(+), 292 deletions(-) diff --git a/src/vendored/r3_hex_api.erl b/src/vendored/r3_hex_api.erl index 1c0586ef..51bae96b 100644 --- a/src/vendored/r3_hex_api.erl +++ b/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 diff --git a/src/vendored/r3_hex_api_key.erl b/src/vendored/r3_hex_api_key.erl index 1fcd7aea..8c93022a 100644 --- a/src/vendored/r3_hex_api_key.erl +++ b/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([ diff --git a/src/vendored/r3_hex_api_package.erl b/src/vendored/r3_hex_api_package.erl index 3cfb4702..71c1ad10 100644 --- a/src/vendored/r3_hex_api_package.erl +++ b/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]). diff --git a/src/vendored/r3_hex_api_package_owner.erl b/src/vendored/r3_hex_api_package_owner.erl index 742104ad..396b2308 100644 --- a/src/vendored/r3_hex_api_package_owner.erl +++ b/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([ diff --git a/src/vendored/r3_hex_api_release.erl b/src/vendored/r3_hex_api_release.erl index f5994dda..92d9fdd2 100644 --- a/src/vendored/r3_hex_api_release.erl +++ b/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"])), diff --git a/src/vendored/r3_hex_api_user.erl b/src/vendored/r3_hex_api_user.erl index 5b4111ad..526f62b8 100644 --- a/src/vendored/r3_hex_api_user.erl +++ b/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([ diff --git a/src/vendored/r3_hex_core.erl b/src/vendored/r3_hex_core.erl index 86832015..de7c8934 100644 --- a/src/vendored/r3_hex_core.erl +++ b/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)">>, diff --git a/src/vendored/r3_hex_core.hrl b/src/vendored/r3_hex_core.hrl index 6f045695..e3dacdab 100644 --- a/src/vendored/r3_hex_core.hrl +++ b/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"). diff --git a/src/vendored/r3_hex_erl_tar.erl b/src/vendored/r3_hex_erl_tar.erl index 18893cee..a015d23f 100644 --- a/src/vendored/r3_hex_erl_tar.erl +++ b/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 diff --git a/src/vendored/r3_hex_erl_tar.hrl b/src/vendored/r3_hex_erl_tar.hrl index bd6395fc..4ddfa539 100644 --- a/src/vendored/r3_hex_erl_tar.hrl +++ b/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 diff --git a/src/vendored/r3_hex_filename.erl b/src/vendored/r3_hex_filename.erl index 3d9f2328..34ebc088 100644 --- a/src/vendored/r3_hex_filename.erl +++ b/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 diff --git a/src/vendored/r3_hex_http.erl b/src/vendored/r3_hex_http.erl index 71cd8bee..19ea90b5 100644 --- a/src/vendored/r3_hex_http.erl +++ b/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) -> diff --git a/src/vendored/r3_hex_http_httpc.erl b/src/vendored/r3_hex_http_httpc.erl index ace8b0e9..79a35477 100644 --- a/src/vendored/r3_hex_http_httpc.erl +++ b/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 diff --git a/src/vendored/r3_hex_pb_names.erl b/src/vendored/r3_hex_pb_names.erl index 02a94b67..420058e8 100644 --- a/src/vendored/r3_hex_pb_names.erl +++ b/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, <>, 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, <>, 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), <>. @@ -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, <> = 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]. diff --git a/src/vendored/r3_hex_pb_package.erl b/src/vendored/r3_hex_pb_package.erl index 208d34b4..7d3c72ad 100644 --- a/src/vendored/r3_hex_pb_package.erl +++ b/src/vendored/r3_hex_pb_package.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.2.1 +%% Generated by gpb_compile version 4.10.0 -module(r3_hex_pb_package). -export([encode_msg/2, encode_msg/3]). @@ -22,7 +23,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]). @@ -33,54 +55,60 @@ %% message types -type 'Package'() :: #{releases => ['Release'()], % = 1 - name => iodata(), % = 2 - repository => iodata() % = 3 + name := iodata(), % = 2 + repository := iodata() % = 3 }. + -type 'Release'() :: - #{version => iodata(), % = 1 - inner_checksum => iodata(), % = 2 - dependencies => ['Dependency'()] % = 3 - %% retired => 'RetirementStatus'() % = 4 - %% outer_checksum => iodata() % = 5 + #{version := iodata(), % = 1 + inner_checksum := iodata(), % = 2 + dependencies => ['Dependency'()], % = 3 + retired => 'RetirementStatus'(), % = 4 + outer_checksum => iodata() % = 5 }. + -type 'RetirementStatus'() :: - #{reason => 'RETIRED_OTHER' | 'RETIRED_INVALID' | 'RETIRED_SECURITY' | 'RETIRED_DEPRECATED' | 'RETIRED_RENAMED' | integer() % = 1, enum RetirementReason - %% message => iodata() % = 2 + #{reason := 'RETIRED_OTHER' | 'RETIRED_INVALID' | 'RETIRED_SECURITY' | 'RETIRED_DEPRECATED' | 'RETIRED_RENAMED' | integer(), % = 1, enum RetirementReason + message => iodata() % = 2 }. + -type 'Dependency'() :: - #{package => iodata(), % = 1 - requirement => iodata() % = 2 - %% optional => boolean() | 0 | 1 % = 3 - %% app => iodata() % = 4 - %% repository => iodata() % = 5 + #{package := iodata(), % = 1 + requirement := iodata(), % = 2 + optional => boolean() | 0 | 1, % = 3 + app => iodata(), % = 4 + repository => iodata() % = 5 }. + -export_type(['Package'/0, 'Release'/0, 'RetirementStatus'/0, 'Dependency'/0]). --spec encode_msg('Package'() | 'Release'() | 'RetirementStatus'() | 'Dependency'(),'Package' | 'Release' | 'RetirementStatus' | 'Dependency') -> binary(). -encode_msg(Msg, MsgName) -> +-spec encode_msg('Package'() | 'Release'() | 'RetirementStatus'() | 'Dependency'(), atom()) -> binary(). +encode_msg(Msg, MsgName) when is_atom(MsgName) -> encode_msg(Msg, MsgName, []). - --spec encode_msg('Package'() | 'Release'() | 'RetirementStatus'() | 'Dependency'(),'Package' | 'Release' | 'RetirementStatus' | 'Dependency', list()) -> binary(). +-spec encode_msg('Package'() | 'Release'() | 'RetirementStatus'() | 'Dependency'(), atom(), list()) -> binary(). encode_msg(Msg, MsgName, Opts) -> verify_msg(Msg, MsgName, Opts), TrUserData = proplists:get_value(user_data, Opts), case MsgName of - 'Package' -> e_msg_Package(Msg, TrUserData); - 'Release' -> e_msg_Release(Msg, TrUserData); + 'Package' -> + encode_msg_Package(id(Msg, TrUserData), TrUserData); + 'Release' -> + encode_msg_Release(id(Msg, TrUserData), TrUserData); 'RetirementStatus' -> - e_msg_RetirementStatus(Msg, TrUserData); - 'Dependency' -> e_msg_Dependency(Msg, TrUserData) + encode_msg_RetirementStatus(id(Msg, TrUserData), + TrUserData); + 'Dependency' -> + encode_msg_Dependency(id(Msg, TrUserData), 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 := F2, repository := F3} = M, Bin, - TrUserData) -> +encode_msg_Package(#{name := F2, repository := F3} = M, + Bin, TrUserData) -> B1 = case M of #{releases := F1} -> TrF1 = id(F1, TrUserData), @@ -91,27 +119,28 @@ e_msg_Package(#{name := F2, repository := F3} = M, Bin, end, B2 = begin TrF2 = id(F2, TrUserData), - e_type_string(TrF2, <>) + e_type_string(TrF2, <>, TrUserData) end, begin TrF3 = id(F3, TrUserData), - e_type_string(TrF3, <>) + e_type_string(TrF3, <>, TrUserData) end. -e_msg_Release(Msg, TrUserData) -> - e_msg_Release(Msg, <<>>, TrUserData). +encode_msg_Release(Msg, TrUserData) -> + encode_msg_Release(Msg, <<>>, TrUserData). -e_msg_Release(#{version := F1, inner_checksum := F2} = - M, - Bin, TrUserData) -> +encode_msg_Release(#{version := F1, + inner_checksum := F2} = + M, + Bin, TrUserData) -> B1 = begin TrF1 = id(F1, TrUserData), - e_type_string(TrF1, <>) + e_type_string(TrF1, <>, TrUserData) end, B2 = begin TrF2 = id(F2, TrUserData), - e_type_bytes(TrF2, <>) + e_type_bytes(TrF2, <>, TrUserData) end, B3 = case M of #{dependencies := F3} -> @@ -135,50 +164,52 @@ e_msg_Release(#{version := F1, inner_checksum := F2} = #{outer_checksum := F5} -> begin TrF5 = id(F5, TrUserData), - e_type_bytes(TrF5, <>) + e_type_bytes(TrF5, <>, TrUserData) end; _ -> B4 end. -e_msg_RetirementStatus(Msg, TrUserData) -> - e_msg_RetirementStatus(Msg, <<>>, TrUserData). +encode_msg_RetirementStatus(Msg, TrUserData) -> + encode_msg_RetirementStatus(Msg, <<>>, TrUserData). -e_msg_RetirementStatus(#{reason := F1} = M, Bin, - TrUserData) -> +encode_msg_RetirementStatus(#{reason := F1} = M, Bin, + TrUserData) -> B1 = begin TrF1 = id(F1, TrUserData), - e_enum_RetirementReason(TrF1, <>) + e_enum_RetirementReason(TrF1, <>, + TrUserData) end, case M of #{message := F2} -> begin TrF2 = id(F2, TrUserData), - e_type_string(TrF2, <>) + e_type_string(TrF2, <>, TrUserData) end; _ -> B1 end. -e_msg_Dependency(Msg, TrUserData) -> - e_msg_Dependency(Msg, <<>>, TrUserData). +encode_msg_Dependency(Msg, TrUserData) -> + encode_msg_Dependency(Msg, <<>>, TrUserData). -e_msg_Dependency(#{package := F1, requirement := F2} = - M, - Bin, TrUserData) -> +encode_msg_Dependency(#{package := F1, + requirement := F2} = + M, + Bin, TrUserData) -> B1 = begin TrF1 = id(F1, TrUserData), - e_type_string(TrF1, <>) + e_type_string(TrF1, <>, TrUserData) end, B2 = begin TrF2 = id(F2, TrUserData), - e_type_string(TrF2, <>) + e_type_string(TrF2, <>, TrUserData) end, B3 = case M of #{optional := F3} -> begin TrF3 = id(F3, TrUserData), - e_type_bool(TrF3, <>) + e_type_bool(TrF3, <>, TrUserData) end; _ -> B2 end, @@ -186,7 +217,7 @@ e_msg_Dependency(#{package := F1, requirement := F2} = #{app := F4} -> begin TrF4 = id(F4, TrUserData), - e_type_string(TrF4, <>) + e_type_string(TrF4, <>, TrUserData) end; _ -> B3 end, @@ -194,13 +225,13 @@ e_msg_Dependency(#{package := F1, requirement := F2} = #{repository := F5} -> begin TrF5 = id(F5, TrUserData), - e_type_string(TrF5, <>) + e_type_string(TrF5, <>, TrUserData) end; _ -> B4 end. e_mfield_Package_releases(Msg, Bin, TrUserData) -> - SubBin = e_msg_Release(Msg, <<>>, TrUserData), + SubBin = encode_msg_Release(Msg, <<>>, TrUserData), Bin2 = e_varint(byte_size(SubBin), Bin), <>. @@ -213,7 +244,7 @@ e_field_Package_releases([Elem | Rest], Bin, e_field_Package_releases([], Bin, _TrUserData) -> Bin. e_mfield_Release_dependencies(Msg, Bin, TrUserData) -> - SubBin = e_msg_Dependency(Msg, <<>>, TrUserData), + SubBin = encode_msg_Dependency(Msg, <<>>, TrUserData), Bin2 = e_varint(byte_size(SubBin), Bin), <>. @@ -228,40 +259,116 @@ e_field_Release_dependencies([], Bin, _TrUserData) -> Bin. e_mfield_Release_retired(Msg, Bin, TrUserData) -> - SubBin = e_msg_RetirementStatus(Msg, <<>>, TrUserData), + SubBin = encode_msg_RetirementStatus(Msg, <<>>, + TrUserData), Bin2 = e_varint(byte_size(SubBin), Bin), <>. -e_enum_RetirementReason('RETIRED_OTHER', Bin) -> +e_enum_RetirementReason('RETIRED_OTHER', Bin, + _TrUserData) -> <>; -e_enum_RetirementReason('RETIRED_INVALID', Bin) -> +e_enum_RetirementReason('RETIRED_INVALID', Bin, + _TrUserData) -> <>; -e_enum_RetirementReason('RETIRED_SECURITY', Bin) -> +e_enum_RetirementReason('RETIRED_SECURITY', Bin, + _TrUserData) -> <>; -e_enum_RetirementReason('RETIRED_DEPRECATED', Bin) -> +e_enum_RetirementReason('RETIRED_DEPRECATED', Bin, + _TrUserData) -> <>; -e_enum_RetirementReason('RETIRED_RENAMED', Bin) -> +e_enum_RetirementReason('RETIRED_RENAMED', Bin, + _TrUserData) -> <>; -e_enum_RetirementReason(V, Bin) -> e_varint(V, Bin). - -e_type_bool(true, Bin) -> <>; -e_type_bool(false, Bin) -> <>; -e_type_bool(1, Bin) -> <>; -e_type_bool(0, Bin) -> <>. +e_enum_RetirementReason(V, Bin, _TrUserData) -> + e_varint(V, Bin). + +-compile({nowarn_unused_function,e_type_sint/3}). +e_type_sint(Value, Bin, _TrUserData) when Value >= 0 -> + e_varint(Value * 2, Bin); +e_type_sint(Value, Bin, _TrUserData) -> + e_varint(Value * -2 - 1, Bin). + +-compile({nowarn_unused_function,e_type_int32/3}). +e_type_int32(Value, Bin, _TrUserData) + when 0 =< Value, Value =< 127 -> + <>; +e_type_int32(Value, Bin, _TrUserData) -> + <> = <>, + e_varint(N, Bin). + +-compile({nowarn_unused_function,e_type_int64/3}). +e_type_int64(Value, Bin, _TrUserData) + when 0 =< Value, Value =< 127 -> + <>; +e_type_int64(Value, Bin, _TrUserData) -> + <> = <>, + e_varint(N, Bin). + +-compile({nowarn_unused_function,e_type_bool/3}). +e_type_bool(true, Bin, _TrUserData) -> + <>; +e_type_bool(false, Bin, _TrUserData) -> + <>; +e_type_bool(1, Bin, _TrUserData) -> <>; +e_type_bool(0, Bin, _TrUserData) -> <>. -e_type_string(S, Bin) -> +-compile({nowarn_unused_function,e_type_string/3}). +e_type_string(S, Bin, _TrUserData) -> Utf8 = unicode:characters_to_binary(S), Bin2 = e_varint(byte_size(Utf8), Bin), <>. -e_type_bytes(Bytes, Bin) when is_binary(Bytes) -> +-compile({nowarn_unused_function,e_type_bytes/3}). +e_type_bytes(Bytes, Bin, _TrUserData) + when is_binary(Bytes) -> Bin2 = e_varint(byte_size(Bytes), Bin), <>; -e_type_bytes(Bytes, Bin) when is_list(Bytes) -> +e_type_bytes(Bytes, Bin, _TrUserData) + when is_list(Bytes) -> BytesBin = iolist_to_binary(Bytes), Bin2 = e_varint(byte_size(BytesBin), Bin), <>. +-compile({nowarn_unused_function,e_type_fixed32/3}). +e_type_fixed32(Value, Bin, _TrUserData) -> + <>. + +-compile({nowarn_unused_function,e_type_sfixed32/3}). +e_type_sfixed32(Value, Bin, _TrUserData) -> + <>. + +-compile({nowarn_unused_function,e_type_fixed64/3}). +e_type_fixed64(Value, Bin, _TrUserData) -> + <>. + +-compile({nowarn_unused_function,e_type_sfixed64/3}). +e_type_sfixed64(Value, Bin, _TrUserData) -> + <>. + +-compile({nowarn_unused_function,e_type_float/3}). +e_type_float(V, Bin, _) when is_number(V) -> + <>; +e_type_float(infinity, Bin, _) -> + <>; +e_type_float('-infinity', Bin, _) -> + <>; +e_type_float(nan, Bin, _) -> + <>. + +-compile({nowarn_unused_function,e_type_double/3}). +e_type_double(V, Bin, _) when is_number(V) -> + <>; +e_type_double(infinity, Bin, _) -> + <>; +e_type_double('-infinity', Bin, _) -> + <>; +e_type_double(nan, Bin, _) -> + <>. + +-compile({nowarn_unused_function,e_varint/3}). +e_varint(N, Bin, _TrUserData) -> e_varint(N, Bin). + +-compile({nowarn_unused_function,e_varint/2}). e_varint(N, Bin) when N =< 127 -> <>; e_varint(N, Bin) -> Bin2 = <>, @@ -281,12 +388,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 -> @@ -295,21 +396,20 @@ decode_msg_1_catch(Bin, MsgName, TrUserData) -> end. -endif. --endif. - decode_msg_2_doit('Package', Bin, TrUserData) -> - d_msg_Package(Bin, TrUserData); + id(decode_msg_Package(Bin, TrUserData), TrUserData); decode_msg_2_doit('Release', Bin, TrUserData) -> - d_msg_Release(Bin, TrUserData); + id(decode_msg_Release(Bin, TrUserData), TrUserData); decode_msg_2_doit('RetirementStatus', Bin, TrUserData) -> - d_msg_RetirementStatus(Bin, TrUserData); + id(decode_msg_RetirementStatus(Bin, TrUserData), + TrUserData); decode_msg_2_doit('Dependency', Bin, TrUserData) -> - d_msg_Dependency(Bin, TrUserData). + id(decode_msg_Dependency(Bin, TrUserData), TrUserData). -d_msg_Package(Bin, TrUserData) -> +decode_msg_Package(Bin, TrUserData) -> dfp_read_field_def_Package(Bin, 0, 0, id([], TrUserData), id('$undef', TrUserData), id('$undef', TrUserData), TrUserData). @@ -328,8 +428,10 @@ dfp_read_field_def_Package(<<26, Rest/binary>>, Z1, Z2, F@_3, TrUserData); dfp_read_field_def_Package(<<>>, 0, 0, R1, F@_2, F@_3, TrUserData) -> - #{releases => lists_reverse(R1, TrUserData), - name => F@_2, repository => F@_3}; + S1 = #{name => F@_2, repository => F@_3}, + if R1 == '$undef' -> S1; + true -> S1#{releases => lists_reverse(R1, TrUserData)} + end; dfp_read_field_def_Package(Other, Z1, Z2, F@_1, F@_2, F@_3, TrUserData) -> dg_read_field_def_Package(Other, Z1, Z2, F@_1, F@_2, @@ -374,8 +476,10 @@ dg_read_field_def_Package(<<0:1, X:7, Rest/binary>>, N, end; dg_read_field_def_Package(<<>>, 0, 0, R1, F@_2, F@_3, TrUserData) -> - #{releases => lists_reverse(R1, TrUserData), - name => F@_2, repository => F@_3}. + S1 = #{name => F@_2, repository => F@_3}, + if R1 == '$undef' -> S1; + true -> S1#{releases => lists_reverse(R1, TrUserData)} + end. d_field_Package_releases(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, TrUserData) @@ -387,7 +491,7 @@ d_field_Package_releases(<<0:1, X:7, Rest/binary>>, N, {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, - {id(d_msg_Release(Bs, TrUserData), TrUserData), + {id(decode_msg_Release(Bs, TrUserData), TrUserData), Rest2} end, dfp_read_field_def_Package(RestF, 0, 0, @@ -404,7 +508,7 @@ d_field_Package_name(<<0:1, X:7, Rest/binary>>, N, Acc, {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, - {binary:copy(Bytes), Rest2} + {id(binary:copy(Bytes), TrUserData), Rest2} end, dfp_read_field_def_Package(RestF, 0, 0, F@_1, NewFValue, F@_3, TrUserData). @@ -419,7 +523,7 @@ d_field_Package_repository(<<0:1, X:7, Rest/binary>>, N, {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, - {binary:copy(Bytes), Rest2} + {id(binary:copy(Bytes), TrUserData), Rest2} end, dfp_read_field_def_Package(RestF, 0, 0, F@_1, F@_2, NewFValue, TrUserData). @@ -461,7 +565,7 @@ skip_64_Package(<<_:64, Rest/binary>>, Z1, Z2, F@_1, dfp_read_field_def_Package(Rest, Z1, Z2, F@_1, F@_2, F@_3, TrUserData). -d_msg_Release(Bin, TrUserData) -> +decode_msg_Release(Bin, TrUserData) -> dfp_read_field_def_Release(Bin, 0, 0, id('$undef', TrUserData), id('$undef', TrUserData), id([], TrUserData), @@ -490,13 +594,16 @@ dfp_read_field_def_Release(<<42, Rest/binary>>, Z1, Z2, F@_3, F@_4, F@_5, TrUserData); dfp_read_field_def_Release(<<>>, 0, 0, F@_1, F@_2, R1, F@_4, F@_5, TrUserData) -> - S1 = #{version => F@_1, inner_checksum => F@_2, - dependencies => lists_reverse(R1, TrUserData)}, - S2 = if F@_4 == '$undef' -> S1; - true -> S1#{retired => F@_4} + S1 = #{version => F@_1, inner_checksum => F@_2}, + S2 = if R1 == '$undef' -> S1; + true -> + S1#{dependencies => lists_reverse(R1, TrUserData)} end, - if F@_5 == '$undef' -> S2; - true -> S2#{outer_checksum => F@_5} + S3 = if F@_4 == '$undef' -> S2; + true -> S2#{retired => F@_4} + end, + if F@_5 == '$undef' -> S3; + true -> S3#{outer_checksum => F@_5} end; dfp_read_field_def_Release(Other, Z1, Z2, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) -> @@ -548,13 +655,16 @@ dg_read_field_def_Release(<<0:1, X:7, Rest/binary>>, N, end; dg_read_field_def_Release(<<>>, 0, 0, F@_1, F@_2, R1, F@_4, F@_5, TrUserData) -> - S1 = #{version => F@_1, inner_checksum => F@_2, - dependencies => lists_reverse(R1, TrUserData)}, - S2 = if F@_4 == '$undef' -> S1; - true -> S1#{retired => F@_4} + S1 = #{version => F@_1, inner_checksum => F@_2}, + S2 = if R1 == '$undef' -> S1; + true -> + S1#{dependencies => lists_reverse(R1, TrUserData)} end, - if F@_5 == '$undef' -> S2; - true -> S2#{outer_checksum => F@_5} + S3 = if F@_4 == '$undef' -> S2; + true -> S2#{retired => F@_4} + end, + if F@_5 == '$undef' -> S3; + true -> S3#{outer_checksum => F@_5} end. d_field_Release_version(<<1:1, X:7, Rest/binary>>, N, @@ -567,7 +677,7 @@ d_field_Release_version(<<0:1, X:7, Rest/binary>>, N, {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, - {binary:copy(Bytes), Rest2} + {id(binary:copy(Bytes), TrUserData), Rest2} end, dfp_read_field_def_Release(RestF, 0, 0, NewFValue, F@_2, F@_3, F@_4, F@_5, TrUserData). @@ -585,7 +695,7 @@ d_field_Release_inner_checksum(<<0:1, X:7, {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, - {binary:copy(Bytes), Rest2} + {id(binary:copy(Bytes), TrUserData), Rest2} end, dfp_read_field_def_Release(RestF, 0, 0, F@_1, NewFValue, F@_3, F@_4, F@_5, TrUserData). @@ -601,7 +711,8 @@ d_field_Release_dependencies(<<0:1, X:7, Rest/binary>>, {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, - {id(d_msg_Dependency(Bs, TrUserData), TrUserData), + {id(decode_msg_Dependency(Bs, TrUserData), + TrUserData), Rest2} end, dfp_read_field_def_Release(RestF, 0, 0, F@_1, F@_2, @@ -618,7 +729,7 @@ d_field_Release_retired(<<0:1, X:7, Rest/binary>>, N, {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, - {id(d_msg_RetirementStatus(Bs, TrUserData), + {id(decode_msg_RetirementStatus(Bs, TrUserData), TrUserData), Rest2} end, @@ -645,7 +756,7 @@ d_field_Release_outer_checksum(<<0:1, X:7, {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, - {binary:copy(Bytes), Rest2} + {id(binary:copy(Bytes), TrUserData), Rest2} end, dfp_read_field_def_Release(RestF, 0, 0, F@_1, F@_2, F@_3, F@_4, NewFValue, TrUserData). @@ -689,7 +800,7 @@ skip_64_Release(<<_:64, Rest/binary>>, Z1, Z2, F@_1, dfp_read_field_def_Release(Rest, Z1, Z2, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData). -d_msg_RetirementStatus(Bin, TrUserData) -> +decode_msg_RetirementStatus(Bin, TrUserData) -> dfp_read_field_def_RetirementStatus(Bin, 0, 0, id('$undef', TrUserData), id('$undef', TrUserData), TrUserData). @@ -765,12 +876,13 @@ d_field_RetirementStatus_reason(<<1:1, X:7, d_field_RetirementStatus_reason(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_2, TrUserData) -> - {NewFValue, RestF} = {d_enum_RetirementReason(begin - <> = - <<(X bsl N + - Acc):32/unsigned-native>>, - Res - end), + {NewFValue, RestF} = {id(d_enum_RetirementReason(begin + <> = + <<(X bsl N + + Acc):32/unsigned-native>>, + id(Res, TrUserData) + end), + TrUserData), Rest}, dfp_read_field_def_RetirementStatus(RestF, 0, 0, NewFValue, F@_2, TrUserData). @@ -787,7 +899,7 @@ d_field_RetirementStatus_message(<<0:1, X:7, {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, - {binary:copy(Bytes), Rest2} + {id(binary:copy(Bytes), TrUserData), Rest2} end, dfp_read_field_def_RetirementStatus(RestF, 0, 0, F@_1, NewFValue, TrUserData). @@ -832,7 +944,7 @@ skip_64_RetirementStatus(<<_:64, Rest/binary>>, Z1, Z2, dfp_read_field_def_RetirementStatus(Rest, Z1, Z2, F@_1, F@_2, TrUserData). -d_msg_Dependency(Bin, TrUserData) -> +decode_msg_Dependency(Bin, TrUserData) -> dfp_read_field_def_Dependency(Bin, 0, 0, id('$undef', TrUserData), id('$undef', TrUserData), @@ -944,7 +1056,7 @@ d_field_Dependency_package(<<0:1, X:7, Rest/binary>>, N, {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, - {binary:copy(Bytes), Rest2} + {id(binary:copy(Bytes), TrUserData), Rest2} end, dfp_read_field_def_Dependency(RestF, 0, 0, NewFValue, F@_2, F@_3, F@_4, F@_5, TrUserData). @@ -962,7 +1074,7 @@ d_field_Dependency_requirement(<<0:1, X:7, {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, - {binary:copy(Bytes), Rest2} + {id(binary:copy(Bytes), TrUserData), Rest2} end, dfp_read_field_def_Dependency(RestF, 0, 0, F@_1, NewFValue, F@_3, F@_4, F@_5, TrUserData). @@ -974,7 +1086,9 @@ d_field_Dependency_optional(<<1:1, X:7, Rest/binary>>, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData); d_field_Dependency_optional(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, _, F@_4, F@_5, TrUserData) -> - {NewFValue, RestF} = {X bsl N + Acc =/= 0, Rest}, + {NewFValue, RestF} = {id(X bsl N + Acc =/= 0, + TrUserData), + Rest}, dfp_read_field_def_Dependency(RestF, 0, 0, F@_1, F@_2, NewFValue, F@_4, F@_5, TrUserData). @@ -988,7 +1102,7 @@ d_field_Dependency_app(<<0:1, X:7, Rest/binary>>, N, {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, - {binary:copy(Bytes), Rest2} + {id(binary:copy(Bytes), TrUserData), Rest2} end, dfp_read_field_def_Dependency(RestF, 0, 0, F@_1, F@_2, F@_3, NewFValue, F@_5, TrUserData). @@ -1004,7 +1118,7 @@ d_field_Dependency_repository(<<0:1, X:7, Rest/binary>>, {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, - {binary:copy(Bytes), Rest2} + {id(binary:copy(Bytes), TrUserData), Rest2} end, dfp_read_field_def_Dependency(RestF, 0, 0, F@_1, F@_2, F@_3, F@_4, NewFValue, TrUserData). @@ -1116,7 +1230,7 @@ read_gr_ld(<<0:1, X:7, Tl/binary>>, N, Acc, NumBytes, FieldNum) -> <<_:Len/binary, Tl2/binary>> = Tl, read_gr_b(Tl2, 0, 0, NumBytes1 + Len, 0, FieldNum). -merge_msgs(Prev, New, MsgName) -> +merge_msgs(Prev, New, MsgName) when is_atom(MsgName) -> merge_msgs(Prev, New, MsgName, []). merge_msgs(Prev, New, MsgName, Opts) -> @@ -1130,6 +1244,7 @@ merge_msgs(Prev, New, MsgName, Opts) -> merge_msg_Dependency(Prev, New, TrUserData) end. +-compile({nowarn_unused_function,merge_msg_Package/3}). merge_msg_Package(#{} = PMsg, #{name := NFname, repository := NFrepository} = NMsg, TrUserData) -> @@ -1146,6 +1261,7 @@ merge_msg_Package(#{} = PMsg, {_, _} -> S1 end. +-compile({nowarn_unused_function,merge_msg_Release/3}). merge_msg_Release(#{} = PMsg, #{version := NFversion, inner_checksum := NFinner_checksum} = @@ -1184,6 +1300,7 @@ merge_msg_Release(#{} = PMsg, _ -> S3 end. +-compile({nowarn_unused_function,merge_msg_RetirementStatus/3}). merge_msg_RetirementStatus(#{} = PMsg, #{reason := NFreason} = NMsg, _) -> S1 = #{reason => NFreason}, @@ -1195,6 +1312,7 @@ merge_msg_RetirementStatus(#{} = PMsg, _ -> S1 end. +-compile({nowarn_unused_function,merge_msg_Dependency/3}). merge_msg_Dependency(#{} = PMsg, #{package := NFpackage, requirement := NFrequirement} = NMsg, @@ -1222,25 +1340,24 @@ merge_msg_Dependency(#{} = PMsg, end. -verify_msg(Msg, MsgName) -> +verify_msg(Msg, MsgName) when is_atom(MsgName) -> verify_msg(Msg, MsgName, []). verify_msg(Msg, MsgName, Opts) -> TrUserData = proplists:get_value(user_data, Opts), case MsgName of - 'Package' -> - v_msg_Package(Msg, ['Package'], TrUserData); - 'Release' -> - v_msg_Release(Msg, ['Release'], TrUserData); + 'Package' -> v_msg_Package(Msg, [MsgName], TrUserData); + 'Release' -> v_msg_Release(Msg, [MsgName], TrUserData); 'RetirementStatus' -> - v_msg_RetirementStatus(Msg, ['RetirementStatus'], - TrUserData); + v_msg_RetirementStatus(Msg, [MsgName], TrUserData); 'Dependency' -> - v_msg_Dependency(Msg, ['Dependency'], TrUserData); + v_msg_Dependency(Msg, [MsgName], TrUserData); _ -> mk_type_error(not_a_known_message, Msg, []) end. +-compile({nowarn_unused_function,v_msg_Package/3}). +-dialyzer({nowarn_function,v_msg_Package/3}). v_msg_Package(#{name := F2, repository := F3} = M, Path, TrUserData) -> case M of @@ -1255,8 +1372,8 @@ v_msg_Package(#{name := F2, repository := F3} = M, Path, end; _ -> ok end, - v_type_string(F2, [name | Path]), - v_type_string(F3, [repository | Path]), + v_type_string(F2, [name | Path], TrUserData), + v_type_string(F3, [repository | Path], TrUserData), lists:foreach(fun (releases) -> ok; (name) -> ok; (repository) -> ok; @@ -1272,11 +1389,13 @@ v_msg_Package(M, Path, _TrUserData) when is_map(M) -> v_msg_Package(X, Path, _TrUserData) -> mk_type_error({expected_msg, 'Package'}, X, Path). +-compile({nowarn_unused_function,v_msg_Release/3}). +-dialyzer({nowarn_function,v_msg_Release/3}). v_msg_Release(#{version := F1, inner_checksum := F2} = M, Path, TrUserData) -> - v_type_string(F1, [version | Path]), - v_type_bytes(F2, [inner_checksum | Path]), + v_type_string(F1, [version | Path], TrUserData), + v_type_bytes(F2, [inner_checksum | Path], TrUserData), case M of #{dependencies := F3} -> if is_list(F3) -> @@ -1298,7 +1417,7 @@ v_msg_Release(#{version := F1, inner_checksum := F2} = end, case M of #{outer_checksum := F5} -> - v_type_bytes(F5, [outer_checksum | Path]); + v_type_bytes(F5, [outer_checksum | Path], TrUserData); _ -> ok end, lists:foreach(fun (version) -> ok; @@ -1318,10 +1437,15 @@ v_msg_Release(M, Path, _TrUserData) when is_map(M) -> v_msg_Release(X, Path, _TrUserData) -> mk_type_error({expected_msg, 'Release'}, X, Path). -v_msg_RetirementStatus(#{reason := F1} = M, Path, _) -> - v_enum_RetirementReason(F1, [reason | Path]), +-compile({nowarn_unused_function,v_msg_RetirementStatus/3}). +-dialyzer({nowarn_function,v_msg_RetirementStatus/3}). +v_msg_RetirementStatus(#{reason := F1} = M, Path, + TrUserData) -> + v_enum_RetirementReason(F1, [reason | Path], + TrUserData), case M of - #{message := F2} -> v_type_string(F2, [message | Path]); + #{message := F2} -> + v_type_string(F2, [message | Path], TrUserData); _ -> ok end, lists:foreach(fun (reason) -> ok; @@ -1340,22 +1464,26 @@ v_msg_RetirementStatus(X, Path, _TrUserData) -> mk_type_error({expected_msg, 'RetirementStatus'}, X, Path). +-compile({nowarn_unused_function,v_msg_Dependency/3}). +-dialyzer({nowarn_function,v_msg_Dependency/3}). v_msg_Dependency(#{package := F1, requirement := F2} = M, - Path, _) -> - v_type_string(F1, [package | Path]), - v_type_string(F2, [requirement | Path]), + Path, TrUserData) -> + v_type_string(F1, [package | Path], TrUserData), + v_type_string(F2, [requirement | Path], TrUserData), case M of - #{optional := F3} -> v_type_bool(F3, [optional | Path]); + #{optional := F3} -> + v_type_bool(F3, [optional | Path], TrUserData); _ -> ok end, case M of - #{app := F4} -> v_type_string(F4, [app | Path]); + #{app := F4} -> + v_type_string(F4, [app | Path], TrUserData); _ -> ok end, case M of #{repository := F5} -> - v_type_string(F5, [repository | Path]); + v_type_string(F5, [repository | Path], TrUserData); _ -> ok end, lists:foreach(fun (package) -> ok; @@ -1375,37 +1503,56 @@ v_msg_Dependency(M, Path, _TrUserData) when is_map(M) -> v_msg_Dependency(X, Path, _TrUserData) -> mk_type_error({expected_msg, 'Dependency'}, X, Path). -v_enum_RetirementReason('RETIRED_OTHER', _Path) -> ok; -v_enum_RetirementReason('RETIRED_INVALID', _Path) -> ok; -v_enum_RetirementReason('RETIRED_SECURITY', _Path) -> +-compile({nowarn_unused_function,v_enum_RetirementReason/3}). +-dialyzer({nowarn_function,v_enum_RetirementReason/3}). +v_enum_RetirementReason('RETIRED_OTHER', _Path, + _TrUserData) -> + ok; +v_enum_RetirementReason('RETIRED_INVALID', _Path, + _TrUserData) -> ok; -v_enum_RetirementReason('RETIRED_DEPRECATED', _Path) -> +v_enum_RetirementReason('RETIRED_SECURITY', _Path, + _TrUserData) -> ok; -v_enum_RetirementReason('RETIRED_RENAMED', _Path) -> ok; -v_enum_RetirementReason(V, Path) when is_integer(V) -> - v_type_sint32(V, Path); -v_enum_RetirementReason(X, Path) -> +v_enum_RetirementReason('RETIRED_DEPRECATED', _Path, + _TrUserData) -> + ok; +v_enum_RetirementReason('RETIRED_RENAMED', _Path, + _TrUserData) -> + ok; +v_enum_RetirementReason(V, Path, TrUserData) + when is_integer(V) -> + v_type_sint32(V, Path, TrUserData); +v_enum_RetirementReason(X, Path, _TrUserData) -> mk_type_error({invalid_enum, 'RetirementReason'}, X, Path). -v_type_sint32(N, _Path) +-compile({nowarn_unused_function,v_type_sint32/3}). +-dialyzer({nowarn_function,v_type_sint32/3}). +v_type_sint32(N, _Path, _TrUserData) when -2147483648 =< N, N =< 2147483647 -> ok; -v_type_sint32(N, Path) when is_integer(N) -> +v_type_sint32(N, Path, _TrUserData) + when is_integer(N) -> mk_type_error({value_out_of_range, sint32, signed, 32}, N, Path); -v_type_sint32(X, Path) -> +v_type_sint32(X, Path, _TrUserData) -> mk_type_error({bad_integer, sint32, signed, 32}, X, Path). -v_type_bool(false, _Path) -> ok; -v_type_bool(true, _Path) -> ok; -v_type_bool(0, _Path) -> ok; -v_type_bool(1, _Path) -> ok; -v_type_bool(X, Path) -> +-compile({nowarn_unused_function,v_type_bool/3}). +-dialyzer({nowarn_function,v_type_bool/3}). +v_type_bool(false, _Path, _TrUserData) -> ok; +v_type_bool(true, _Path, _TrUserData) -> ok; +v_type_bool(0, _Path, _TrUserData) -> ok; +v_type_bool(1, _Path, _TrUserData) -> ok; +v_type_bool(X, Path, _TrUserData) -> mk_type_error(bad_boolean_value, X, Path). -v_type_string(S, Path) when is_list(S); is_binary(S) -> +-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 B when is_binary(B) -> ok; {error, _, _} -> @@ -1414,14 +1561,19 @@ v_type_string(S, Path) when is_list(S); is_binary(S) -> error:badarg -> mk_type_error(bad_unicode_string, S, Path) end; -v_type_string(X, Path) -> +v_type_string(X, Path, _TrUserData) -> mk_type_error(bad_unicode_string, X, Path). -v_type_bytes(B, _Path) when is_binary(B) -> ok; -v_type_bytes(B, _Path) when is_list(B) -> ok; -v_type_bytes(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) -> + ok; +v_type_bytes(X, Path, _TrUserData) -> mk_type_error(bad_binary_value, X, Path). +-compile({nowarn_unused_function,mk_type_error/3}). -spec mk_type_error(_, _, list()) -> no_return(). mk_type_error(Error, ValueSeen, Path) -> Path2 = prettify_path(Path), @@ -1429,24 +1581,39 @@ mk_type_error(Error, ValueSeen, Path) -> {Error, [{value, ValueSeen}, {path, Path2}]}}). +-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}). -compile({inline,id/2}). id(X, _TrUserData) -> X. +-compile({nowarn_unused_function,v_ok/3}). +-compile({inline,v_ok/3}). +v_ok(_Value, _Path, _TrUserData) -> ok. + +-compile({nowarn_unused_function,m_overwrite/3}). +-compile({inline,m_overwrite/3}). +m_overwrite(_Prev, New, _TrUserData) -> New. + +-compile({nowarn_unused_function,cons/3}). -compile({inline,cons/3}). cons(Elem, Acc, _TrUserData) -> [Elem | Acc]. +-compile({nowarn_unused_function,lists_reverse/2}). -compile({inline,lists_reverse/2}). 'lists_reverse'(L, _TrUserData) -> lists:reverse(L). +-compile({nowarn_unused_function,'erlang_++'/3}). -compile({inline,'erlang_++'/3}). 'erlang_++'(A, B, _TrUserData) -> A ++ B. + get_msg_defs() -> [{{enum, 'RetirementReason'}, [{'RETIRED_OTHER', 0}, {'RETIRED_INVALID', 1}, @@ -1620,12 +1787,146 @@ 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(<<"Package">>) -> 'Package'; +fqbin_to_msg_name(<<"Release">>) -> 'Release'; +fqbin_to_msg_name(<<"RetirementStatus">>) -> 'RetirementStatus'; +fqbin_to_msg_name(<<"Dependency">>) -> 'Dependency'; +fqbin_to_msg_name(E) -> error({gpb_error, {badmsg, E}}). + + +msg_name_to_fqbin('Package') -> <<"Package">>; +msg_name_to_fqbin('Release') -> <<"Release">>; +msg_name_to_fqbin('RetirementStatus') -> <<"RetirementStatus">>; +msg_name_to_fqbin('Dependency') -> <<"Dependency">>; +msg_name_to_fqbin(E) -> error({gpb_error, {badmsg, E}}). + + +fqbin_to_enum_name(<<"RetirementReason">>) -> 'RetirementReason'; +fqbin_to_enum_name(E) -> + error({gpb_error, {badenum, E}}). + + +enum_name_to_fqbin('RetirementReason') -> <<"RetirementReason">>; +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_package.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_package.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_package"]. + + +get_msg_containment("r3_hex_pb_package") -> + ['Dependency', 'Package', 'Release', + 'RetirementStatus']; +get_msg_containment(P) -> + error({gpb_error, {badproto, P}}). + + +get_pkg_containment("r3_hex_pb_package") -> undefined; +get_pkg_containment(P) -> + error({gpb_error, {badproto, P}}). + + +get_service_containment("r3_hex_pb_package") -> []; +get_service_containment(P) -> + error({gpb_error, {badproto, P}}). + + +get_rpc_containment("r3_hex_pb_package") -> []; +get_rpc_containment(P) -> + error({gpb_error, {badproto, P}}). + + +get_enum_containment("r3_hex_pb_package") -> + ['RetirementReason']; +get_enum_containment(P) -> + error({gpb_error, {badproto, P}}). + + +get_proto_by_msg_name_as_fqbin(<<"RetirementStatus">>) -> + "r3_hex_pb_package"; +get_proto_by_msg_name_as_fqbin(<<"Release">>) -> + "r3_hex_pb_package"; +get_proto_by_msg_name_as_fqbin(<<"Package">>) -> + "r3_hex_pb_package"; +get_proto_by_msg_name_as_fqbin(<<"Dependency">>) -> + "r3_hex_pb_package"; +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}}). + + +get_proto_by_enum_name_as_fqbin(<<"RetirementReason">>) -> + "r3_hex_pb_package"; +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.2.1". + "4.10.0". gpb_version_as_list() -> - [4,2,1]. + [4,10,0]. diff --git a/src/vendored/r3_hex_pb_signed.erl b/src/vendored/r3_hex_pb_signed.erl index 5e6df79a..87645c18 100644 --- a/src/vendored/r3_hex_pb_signed.erl +++ b/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(), % = 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, <>, 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]. diff --git a/src/vendored/r3_hex_pb_versions.erl b/src/vendored/r3_hex_pb_versions.erl index a8d64d8b..f86f02a3 100644 --- a/src/vendored/r3_hex_pb_versions.erl +++ b/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, <>, 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, <>, 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), <>. @@ -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, <> = 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]. diff --git a/src/vendored/r3_hex_registry.erl b/src/vendored/r3_hex_registry.erl index f12aabde..6c5ae3c9 100644 --- a/src/vendored/r3_hex_registry.erl +++ b/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 diff --git a/src/vendored/r3_hex_repo.erl b/src/vendored/r3_hex_repo.erl index b16943fd..50c7b11f 100644 --- a/src/vendored/r3_hex_repo.erl +++ b/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 diff --git a/src/vendored/r3_hex_tarball.erl b/src/vendored/r3_hex_tarball.erl index 2506125c..7663f6a5 100644 --- a/src/vendored/r3_hex_tarball.erl +++ b/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: %% diff --git a/src/vendored/r3_safe_erl_term.xrl b/src/vendored/r3_safe_erl_term.xrl index ffee21c5..7ee78a7d 100644 --- a/src/vendored/r3_safe_erl_term.xrl +++ b/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. diff --git a/vendor_hex_core.sh b/vendor_hex_core.sh index 7c4892e2..6fbedaec 100755 --- a/vendor_hex_core.sh +++ b/vendor_hex_core.sh @@ -14,5 +14,5 @@ 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" \; +find src -regex '.*r3_.*' -exec mv -f {} "$REBAR3_TOP/src/vendored" \; popd From e871da9e85ea271740bea0db28129925a5160180 Mon Sep 17 00:00:00 2001 From: "Paulo F. Oliveira" Date: Tue, 17 Nov 2020 22:24:43 +0000 Subject: [PATCH 15/17] Adapt to hex_core's deprecation warnings We adapt .gitignore to the new vendored folder, also --- .gitignore | 4 ++-- test/rebar_pkg_repos_SUITE.erl | 18 +++++++++--------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.gitignore b/.gitignore index 27a48284..b8febc73 100644 --- a/.gitignore +++ b/.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 diff --git a/test/rebar_pkg_repos_SUITE.erl b/test/rebar_pkg_repos_SUITE.erl index 3d021c8c..24d10fe5 100644 --- a/test/rebar_pkg_repos_SUITE.erl +++ b/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)). From d472b128ab9e7b26f67ad896f2df2cb6bcbe6be9 Mon Sep 17 00:00:00 2001 From: "Paulo F. Oliveira" Date: Tue, 17 Nov 2020 22:38:38 +0000 Subject: [PATCH 16/17] Remove unexpected field from hex_core config. map --- src/rebar_packages.erl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/rebar_packages.erl b/src/rebar_packages.erl index 1f403da3..34d41041 100644 --- a/src/rebar_packages.erl +++ b/src/rebar_packages.erl @@ -269,6 +269,8 @@ update_package(Name, RepoConfig=#{name := Repo}, State) -> 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. From 8390ef348cef4e827240fe7f1e74d352c9445f33 Mon Sep 17 00:00:00 2001 From: "Paulo F. Oliveira" Date: Tue, 17 Nov 2020 22:40:19 +0000 Subject: [PATCH 17/17] Adapt to hex_core's deprecation warnings (II) --- src/rebar_pkg_resource.erl | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/rebar_pkg_resource.erl b/src/rebar_pkg_resource.erl index 91c82a1c..23e9a6f7 100644 --- a/src/rebar_pkg_resource.erl +++ b/src/rebar_pkg_resource.erl @@ -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}),