Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

594 linhas
24 KiB

support for hex v2, multiple repository fetching, private organizations (#1884) * update to hex_core for hex-v2 repo support (#1865) * update to hex_core for hex-v2 repo support This patch adds only single repo hex-v2 support through hex_core. Packages no longer filtered out by buildtool metadata and the package index is updated per-package instead of fetched as one large ets dump. * tell travis to also build hex_core branch * support list of repos for hex packages (#1866) * support list of repos for hex packages repos are defined under the hex key in rebar configs. They can be defined at the top level of a project or globally, but not in profiles and the repos configured in dependencies are also ignored. Searching for packages involves first checking for a match in the local repo index cache, in the order repos are defined. If not found each repo is checked through the hex api for any known versions of the package and the first repo with a version that fits the constraint is used. * add {repos, replace, []} for overriding the global & default repos * add hex auth handling for repos (#1874) auth token are kept in a hex.config file that is modified by the rebar3 hex plugin. Repo names that have a : separating a parent and child are considered organizations. The parent repo's auth will be included with the child. So an organization named hexpm:rebar3_test will include any hexpm auth tokens found in the rebar3_test organization's configuration. * move packages to top level of of hexpm cache dir (#1876) * move packages to top level of of hexpm cache dir * append organization name to parent's repo_url when parsing repos * only eval config scripts and apply overrides once per app (#1879) * only eval config scripts and apply overrides once per app * move new resource behaviour to rebar_resource_v2 and keep v1 * cleanup use of rebar_resource module and unused functions * cleanup error messages and unused code * when discovering apps support mix packages as unbuilt apps (#1882) * use hex_core tarball unpacking support in pkg resource (#1883) * use hex_core tarball unpacking support in pkg resource * ignore etag if package doesn't exist and delete if checksum fails * add back tests for bad package checksums * improve bad registry checksum error message
há 6 anos
support for hex v2, multiple repository fetching, private organizations (#1884) * update to hex_core for hex-v2 repo support (#1865) * update to hex_core for hex-v2 repo support This patch adds only single repo hex-v2 support through hex_core. Packages no longer filtered out by buildtool metadata and the package index is updated per-package instead of fetched as one large ets dump. * tell travis to also build hex_core branch * support list of repos for hex packages (#1866) * support list of repos for hex packages repos are defined under the hex key in rebar configs. They can be defined at the top level of a project or globally, but not in profiles and the repos configured in dependencies are also ignored. Searching for packages involves first checking for a match in the local repo index cache, in the order repos are defined. If not found each repo is checked through the hex api for any known versions of the package and the first repo with a version that fits the constraint is used. * add {repos, replace, []} for overriding the global & default repos * add hex auth handling for repos (#1874) auth token are kept in a hex.config file that is modified by the rebar3 hex plugin. Repo names that have a : separating a parent and child are considered organizations. The parent repo's auth will be included with the child. So an organization named hexpm:rebar3_test will include any hexpm auth tokens found in the rebar3_test organization's configuration. * move packages to top level of of hexpm cache dir (#1876) * move packages to top level of of hexpm cache dir * append organization name to parent's repo_url when parsing repos * only eval config scripts and apply overrides once per app (#1879) * only eval config scripts and apply overrides once per app * move new resource behaviour to rebar_resource_v2 and keep v1 * cleanup use of rebar_resource module and unused functions * cleanup error messages and unused code * when discovering apps support mix packages as unbuilt apps (#1882) * use hex_core tarball unpacking support in pkg resource (#1883) * use hex_core tarball unpacking support in pkg resource * ignore etag if package doesn't exist and delete if checksum fails * add back tests for bad package checksums * improve bad registry checksum error message
há 6 anos
support for hex v2, multiple repository fetching, private organizations (#1884) * update to hex_core for hex-v2 repo support (#1865) * update to hex_core for hex-v2 repo support This patch adds only single repo hex-v2 support through hex_core. Packages no longer filtered out by buildtool metadata and the package index is updated per-package instead of fetched as one large ets dump. * tell travis to also build hex_core branch * support list of repos for hex packages (#1866) * support list of repos for hex packages repos are defined under the hex key in rebar configs. They can be defined at the top level of a project or globally, but not in profiles and the repos configured in dependencies are also ignored. Searching for packages involves first checking for a match in the local repo index cache, in the order repos are defined. If not found each repo is checked through the hex api for any known versions of the package and the first repo with a version that fits the constraint is used. * add {repos, replace, []} for overriding the global & default repos * add hex auth handling for repos (#1874) auth token are kept in a hex.config file that is modified by the rebar3 hex plugin. Repo names that have a : separating a parent and child are considered organizations. The parent repo's auth will be included with the child. So an organization named hexpm:rebar3_test will include any hexpm auth tokens found in the rebar3_test organization's configuration. * move packages to top level of of hexpm cache dir (#1876) * move packages to top level of of hexpm cache dir * append organization name to parent's repo_url when parsing repos * only eval config scripts and apply overrides once per app (#1879) * only eval config scripts and apply overrides once per app * move new resource behaviour to rebar_resource_v2 and keep v1 * cleanup use of rebar_resource module and unused functions * cleanup error messages and unused code * when discovering apps support mix packages as unbuilt apps (#1882) * use hex_core tarball unpacking support in pkg resource (#1883) * use hex_core tarball unpacking support in pkg resource * ignore etag if package doesn't exist and delete if checksum fails * add back tests for bad package checksums * improve bad registry checksum error message
há 6 anos
support for hex v2, multiple repository fetching, private organizations (#1884) * update to hex_core for hex-v2 repo support (#1865) * update to hex_core for hex-v2 repo support This patch adds only single repo hex-v2 support through hex_core. Packages no longer filtered out by buildtool metadata and the package index is updated per-package instead of fetched as one large ets dump. * tell travis to also build hex_core branch * support list of repos for hex packages (#1866) * support list of repos for hex packages repos are defined under the hex key in rebar configs. They can be defined at the top level of a project or globally, but not in profiles and the repos configured in dependencies are also ignored. Searching for packages involves first checking for a match in the local repo index cache, in the order repos are defined. If not found each repo is checked through the hex api for any known versions of the package and the first repo with a version that fits the constraint is used. * add {repos, replace, []} for overriding the global & default repos * add hex auth handling for repos (#1874) auth token are kept in a hex.config file that is modified by the rebar3 hex plugin. Repo names that have a : separating a parent and child are considered organizations. The parent repo's auth will be included with the child. So an organization named hexpm:rebar3_test will include any hexpm auth tokens found in the rebar3_test organization's configuration. * move packages to top level of of hexpm cache dir (#1876) * move packages to top level of of hexpm cache dir * append organization name to parent's repo_url when parsing repos * only eval config scripts and apply overrides once per app (#1879) * only eval config scripts and apply overrides once per app * move new resource behaviour to rebar_resource_v2 and keep v1 * cleanup use of rebar_resource module and unused functions * cleanup error messages and unused code * when discovering apps support mix packages as unbuilt apps (#1882) * use hex_core tarball unpacking support in pkg resource (#1883) * use hex_core tarball unpacking support in pkg resource * ignore etag if package doesn't exist and delete if checksum fails * add back tests for bad package checksums * improve bad registry checksum error message
há 6 anos
support for hex v2, multiple repository fetching, private organizations (#1884) * update to hex_core for hex-v2 repo support (#1865) * update to hex_core for hex-v2 repo support This patch adds only single repo hex-v2 support through hex_core. Packages no longer filtered out by buildtool metadata and the package index is updated per-package instead of fetched as one large ets dump. * tell travis to also build hex_core branch * support list of repos for hex packages (#1866) * support list of repos for hex packages repos are defined under the hex key in rebar configs. They can be defined at the top level of a project or globally, but not in profiles and the repos configured in dependencies are also ignored. Searching for packages involves first checking for a match in the local repo index cache, in the order repos are defined. If not found each repo is checked through the hex api for any known versions of the package and the first repo with a version that fits the constraint is used. * add {repos, replace, []} for overriding the global & default repos * add hex auth handling for repos (#1874) auth token are kept in a hex.config file that is modified by the rebar3 hex plugin. Repo names that have a : separating a parent and child are considered organizations. The parent repo's auth will be included with the child. So an organization named hexpm:rebar3_test will include any hexpm auth tokens found in the rebar3_test organization's configuration. * move packages to top level of of hexpm cache dir (#1876) * move packages to top level of of hexpm cache dir * append organization name to parent's repo_url when parsing repos * only eval config scripts and apply overrides once per app (#1879) * only eval config scripts and apply overrides once per app * move new resource behaviour to rebar_resource_v2 and keep v1 * cleanup use of rebar_resource module and unused functions * cleanup error messages and unused code * when discovering apps support mix packages as unbuilt apps (#1882) * use hex_core tarball unpacking support in pkg resource (#1883) * use hex_core tarball unpacking support in pkg resource * ignore etag if package doesn't exist and delete if checksum fails * add back tests for bad package checksums * improve bad registry checksum error message
há 6 anos
support for hex v2, multiple repository fetching, private organizations (#1884) * update to hex_core for hex-v2 repo support (#1865) * update to hex_core for hex-v2 repo support This patch adds only single repo hex-v2 support through hex_core. Packages no longer filtered out by buildtool metadata and the package index is updated per-package instead of fetched as one large ets dump. * tell travis to also build hex_core branch * support list of repos for hex packages (#1866) * support list of repos for hex packages repos are defined under the hex key in rebar configs. They can be defined at the top level of a project or globally, but not in profiles and the repos configured in dependencies are also ignored. Searching for packages involves first checking for a match in the local repo index cache, in the order repos are defined. If not found each repo is checked through the hex api for any known versions of the package and the first repo with a version that fits the constraint is used. * add {repos, replace, []} for overriding the global & default repos * add hex auth handling for repos (#1874) auth token are kept in a hex.config file that is modified by the rebar3 hex plugin. Repo names that have a : separating a parent and child are considered organizations. The parent repo's auth will be included with the child. So an organization named hexpm:rebar3_test will include any hexpm auth tokens found in the rebar3_test organization's configuration. * move packages to top level of of hexpm cache dir (#1876) * move packages to top level of of hexpm cache dir * append organization name to parent's repo_url when parsing repos * only eval config scripts and apply overrides once per app (#1879) * only eval config scripts and apply overrides once per app * move new resource behaviour to rebar_resource_v2 and keep v1 * cleanup use of rebar_resource module and unused functions * cleanup error messages and unused code * when discovering apps support mix packages as unbuilt apps (#1882) * use hex_core tarball unpacking support in pkg resource (#1883) * use hex_core tarball unpacking support in pkg resource * ignore etag if package doesn't exist and delete if checksum fails * add back tests for bad package checksums * improve bad registry checksum error message
há 6 anos
support for hex v2, multiple repository fetching, private organizations (#1884) * update to hex_core for hex-v2 repo support (#1865) * update to hex_core for hex-v2 repo support This patch adds only single repo hex-v2 support through hex_core. Packages no longer filtered out by buildtool metadata and the package index is updated per-package instead of fetched as one large ets dump. * tell travis to also build hex_core branch * support list of repos for hex packages (#1866) * support list of repos for hex packages repos are defined under the hex key in rebar configs. They can be defined at the top level of a project or globally, but not in profiles and the repos configured in dependencies are also ignored. Searching for packages involves first checking for a match in the local repo index cache, in the order repos are defined. If not found each repo is checked through the hex api for any known versions of the package and the first repo with a version that fits the constraint is used. * add {repos, replace, []} for overriding the global & default repos * add hex auth handling for repos (#1874) auth token are kept in a hex.config file that is modified by the rebar3 hex plugin. Repo names that have a : separating a parent and child are considered organizations. The parent repo's auth will be included with the child. So an organization named hexpm:rebar3_test will include any hexpm auth tokens found in the rebar3_test organization's configuration. * move packages to top level of of hexpm cache dir (#1876) * move packages to top level of of hexpm cache dir * append organization name to parent's repo_url when parsing repos * only eval config scripts and apply overrides once per app (#1879) * only eval config scripts and apply overrides once per app * move new resource behaviour to rebar_resource_v2 and keep v1 * cleanup use of rebar_resource module and unused functions * cleanup error messages and unused code * when discovering apps support mix packages as unbuilt apps (#1882) * use hex_core tarball unpacking support in pkg resource (#1883) * use hex_core tarball unpacking support in pkg resource * ignore etag if package doesn't exist and delete if checksum fails * add back tests for bad package checksums * improve bad registry checksum error message
há 6 anos
support for hex v2, multiple repository fetching, private organizations (#1884) * update to hex_core for hex-v2 repo support (#1865) * update to hex_core for hex-v2 repo support This patch adds only single repo hex-v2 support through hex_core. Packages no longer filtered out by buildtool metadata and the package index is updated per-package instead of fetched as one large ets dump. * tell travis to also build hex_core branch * support list of repos for hex packages (#1866) * support list of repos for hex packages repos are defined under the hex key in rebar configs. They can be defined at the top level of a project or globally, but not in profiles and the repos configured in dependencies are also ignored. Searching for packages involves first checking for a match in the local repo index cache, in the order repos are defined. If not found each repo is checked through the hex api for any known versions of the package and the first repo with a version that fits the constraint is used. * add {repos, replace, []} for overriding the global & default repos * add hex auth handling for repos (#1874) auth token are kept in a hex.config file that is modified by the rebar3 hex plugin. Repo names that have a : separating a parent and child are considered organizations. The parent repo's auth will be included with the child. So an organization named hexpm:rebar3_test will include any hexpm auth tokens found in the rebar3_test organization's configuration. * move packages to top level of of hexpm cache dir (#1876) * move packages to top level of of hexpm cache dir * append organization name to parent's repo_url when parsing repos * only eval config scripts and apply overrides once per app (#1879) * only eval config scripts and apply overrides once per app * move new resource behaviour to rebar_resource_v2 and keep v1 * cleanup use of rebar_resource module and unused functions * cleanup error messages and unused code * when discovering apps support mix packages as unbuilt apps (#1882) * use hex_core tarball unpacking support in pkg resource (#1883) * use hex_core tarball unpacking support in pkg resource * ignore etag if package doesn't exist and delete if checksum fails * add back tests for bad package checksums * improve bad registry checksum error message
há 6 anos
support for hex v2, multiple repository fetching, private organizations (#1884) * update to hex_core for hex-v2 repo support (#1865) * update to hex_core for hex-v2 repo support This patch adds only single repo hex-v2 support through hex_core. Packages no longer filtered out by buildtool metadata and the package index is updated per-package instead of fetched as one large ets dump. * tell travis to also build hex_core branch * support list of repos for hex packages (#1866) * support list of repos for hex packages repos are defined under the hex key in rebar configs. They can be defined at the top level of a project or globally, but not in profiles and the repos configured in dependencies are also ignored. Searching for packages involves first checking for a match in the local repo index cache, in the order repos are defined. If not found each repo is checked through the hex api for any known versions of the package and the first repo with a version that fits the constraint is used. * add {repos, replace, []} for overriding the global & default repos * add hex auth handling for repos (#1874) auth token are kept in a hex.config file that is modified by the rebar3 hex plugin. Repo names that have a : separating a parent and child are considered organizations. The parent repo's auth will be included with the child. So an organization named hexpm:rebar3_test will include any hexpm auth tokens found in the rebar3_test organization's configuration. * move packages to top level of of hexpm cache dir (#1876) * move packages to top level of of hexpm cache dir * append organization name to parent's repo_url when parsing repos * only eval config scripts and apply overrides once per app (#1879) * only eval config scripts and apply overrides once per app * move new resource behaviour to rebar_resource_v2 and keep v1 * cleanup use of rebar_resource module and unused functions * cleanup error messages and unused code * when discovering apps support mix packages as unbuilt apps (#1882) * use hex_core tarball unpacking support in pkg resource (#1883) * use hex_core tarball unpacking support in pkg resource * ignore etag if package doesn't exist and delete if checksum fails * add back tests for bad package checksums * improve bad registry checksum error message
há 6 anos
support for hex v2, multiple repository fetching, private organizations (#1884) * update to hex_core for hex-v2 repo support (#1865) * update to hex_core for hex-v2 repo support This patch adds only single repo hex-v2 support through hex_core. Packages no longer filtered out by buildtool metadata and the package index is updated per-package instead of fetched as one large ets dump. * tell travis to also build hex_core branch * support list of repos for hex packages (#1866) * support list of repos for hex packages repos are defined under the hex key in rebar configs. They can be defined at the top level of a project or globally, but not in profiles and the repos configured in dependencies are also ignored. Searching for packages involves first checking for a match in the local repo index cache, in the order repos are defined. If not found each repo is checked through the hex api for any known versions of the package and the first repo with a version that fits the constraint is used. * add {repos, replace, []} for overriding the global & default repos * add hex auth handling for repos (#1874) auth token are kept in a hex.config file that is modified by the rebar3 hex plugin. Repo names that have a : separating a parent and child are considered organizations. The parent repo's auth will be included with the child. So an organization named hexpm:rebar3_test will include any hexpm auth tokens found in the rebar3_test organization's configuration. * move packages to top level of of hexpm cache dir (#1876) * move packages to top level of of hexpm cache dir * append organization name to parent's repo_url when parsing repos * only eval config scripts and apply overrides once per app (#1879) * only eval config scripts and apply overrides once per app * move new resource behaviour to rebar_resource_v2 and keep v1 * cleanup use of rebar_resource module and unused functions * cleanup error messages and unused code * when discovering apps support mix packages as unbuilt apps (#1882) * use hex_core tarball unpacking support in pkg resource (#1883) * use hex_core tarball unpacking support in pkg resource * ignore etag if package doesn't exist and delete if checksum fails * add back tests for bad package checksums * improve bad registry checksum error message
há 6 anos
support for hex v2, multiple repository fetching, private organizations (#1884) * update to hex_core for hex-v2 repo support (#1865) * update to hex_core for hex-v2 repo support This patch adds only single repo hex-v2 support through hex_core. Packages no longer filtered out by buildtool metadata and the package index is updated per-package instead of fetched as one large ets dump. * tell travis to also build hex_core branch * support list of repos for hex packages (#1866) * support list of repos for hex packages repos are defined under the hex key in rebar configs. They can be defined at the top level of a project or globally, but not in profiles and the repos configured in dependencies are also ignored. Searching for packages involves first checking for a match in the local repo index cache, in the order repos are defined. If not found each repo is checked through the hex api for any known versions of the package and the first repo with a version that fits the constraint is used. * add {repos, replace, []} for overriding the global & default repos * add hex auth handling for repos (#1874) auth token are kept in a hex.config file that is modified by the rebar3 hex plugin. Repo names that have a : separating a parent and child are considered organizations. The parent repo's auth will be included with the child. So an organization named hexpm:rebar3_test will include any hexpm auth tokens found in the rebar3_test organization's configuration. * move packages to top level of of hexpm cache dir (#1876) * move packages to top level of of hexpm cache dir * append organization name to parent's repo_url when parsing repos * only eval config scripts and apply overrides once per app (#1879) * only eval config scripts and apply overrides once per app * move new resource behaviour to rebar_resource_v2 and keep v1 * cleanup use of rebar_resource module and unused functions * cleanup error messages and unused code * when discovering apps support mix packages as unbuilt apps (#1882) * use hex_core tarball unpacking support in pkg resource (#1883) * use hex_core tarball unpacking support in pkg resource * ignore etag if package doesn't exist and delete if checksum fails * add back tests for bad package checksums * improve bad registry checksum error message
há 6 anos
support for hex v2, multiple repository fetching, private organizations (#1884) * update to hex_core for hex-v2 repo support (#1865) * update to hex_core for hex-v2 repo support This patch adds only single repo hex-v2 support through hex_core. Packages no longer filtered out by buildtool metadata and the package index is updated per-package instead of fetched as one large ets dump. * tell travis to also build hex_core branch * support list of repos for hex packages (#1866) * support list of repos for hex packages repos are defined under the hex key in rebar configs. They can be defined at the top level of a project or globally, but not in profiles and the repos configured in dependencies are also ignored. Searching for packages involves first checking for a match in the local repo index cache, in the order repos are defined. If not found each repo is checked through the hex api for any known versions of the package and the first repo with a version that fits the constraint is used. * add {repos, replace, []} for overriding the global & default repos * add hex auth handling for repos (#1874) auth token are kept in a hex.config file that is modified by the rebar3 hex plugin. Repo names that have a : separating a parent and child are considered organizations. The parent repo's auth will be included with the child. So an organization named hexpm:rebar3_test will include any hexpm auth tokens found in the rebar3_test organization's configuration. * move packages to top level of of hexpm cache dir (#1876) * move packages to top level of of hexpm cache dir * append organization name to parent's repo_url when parsing repos * only eval config scripts and apply overrides once per app (#1879) * only eval config scripts and apply overrides once per app * move new resource behaviour to rebar_resource_v2 and keep v1 * cleanup use of rebar_resource module and unused functions * cleanup error messages and unused code * when discovering apps support mix packages as unbuilt apps (#1882) * use hex_core tarball unpacking support in pkg resource (#1883) * use hex_core tarball unpacking support in pkg resource * ignore etag if package doesn't exist and delete if checksum fails * add back tests for bad package checksums * improve bad registry checksum error message
há 6 anos
support for hex v2, multiple repository fetching, private organizations (#1884) * update to hex_core for hex-v2 repo support (#1865) * update to hex_core for hex-v2 repo support This patch adds only single repo hex-v2 support through hex_core. Packages no longer filtered out by buildtool metadata and the package index is updated per-package instead of fetched as one large ets dump. * tell travis to also build hex_core branch * support list of repos for hex packages (#1866) * support list of repos for hex packages repos are defined under the hex key in rebar configs. They can be defined at the top level of a project or globally, but not in profiles and the repos configured in dependencies are also ignored. Searching for packages involves first checking for a match in the local repo index cache, in the order repos are defined. If not found each repo is checked through the hex api for any known versions of the package and the first repo with a version that fits the constraint is used. * add {repos, replace, []} for overriding the global & default repos * add hex auth handling for repos (#1874) auth token are kept in a hex.config file that is modified by the rebar3 hex plugin. Repo names that have a : separating a parent and child are considered organizations. The parent repo's auth will be included with the child. So an organization named hexpm:rebar3_test will include any hexpm auth tokens found in the rebar3_test organization's configuration. * move packages to top level of of hexpm cache dir (#1876) * move packages to top level of of hexpm cache dir * append organization name to parent's repo_url when parsing repos * only eval config scripts and apply overrides once per app (#1879) * only eval config scripts and apply overrides once per app * move new resource behaviour to rebar_resource_v2 and keep v1 * cleanup use of rebar_resource module and unused functions * cleanup error messages and unused code * when discovering apps support mix packages as unbuilt apps (#1882) * use hex_core tarball unpacking support in pkg resource (#1883) * use hex_core tarball unpacking support in pkg resource * ignore etag if package doesn't exist and delete if checksum fails * add back tests for bad package checksums * improve bad registry checksum error message
há 6 anos
support for hex v2, multiple repository fetching, private organizations (#1884) * update to hex_core for hex-v2 repo support (#1865) * update to hex_core for hex-v2 repo support This patch adds only single repo hex-v2 support through hex_core. Packages no longer filtered out by buildtool metadata and the package index is updated per-package instead of fetched as one large ets dump. * tell travis to also build hex_core branch * support list of repos for hex packages (#1866) * support list of repos for hex packages repos are defined under the hex key in rebar configs. They can be defined at the top level of a project or globally, but not in profiles and the repos configured in dependencies are also ignored. Searching for packages involves first checking for a match in the local repo index cache, in the order repos are defined. If not found each repo is checked through the hex api for any known versions of the package and the first repo with a version that fits the constraint is used. * add {repos, replace, []} for overriding the global & default repos * add hex auth handling for repos (#1874) auth token are kept in a hex.config file that is modified by the rebar3 hex plugin. Repo names that have a : separating a parent and child are considered organizations. The parent repo's auth will be included with the child. So an organization named hexpm:rebar3_test will include any hexpm auth tokens found in the rebar3_test organization's configuration. * move packages to top level of of hexpm cache dir (#1876) * move packages to top level of of hexpm cache dir * append organization name to parent's repo_url when parsing repos * only eval config scripts and apply overrides once per app (#1879) * only eval config scripts and apply overrides once per app * move new resource behaviour to rebar_resource_v2 and keep v1 * cleanup use of rebar_resource module and unused functions * cleanup error messages and unused code * when discovering apps support mix packages as unbuilt apps (#1882) * use hex_core tarball unpacking support in pkg resource (#1883) * use hex_core tarball unpacking support in pkg resource * ignore etag if package doesn't exist and delete if checksum fails * add back tests for bad package checksums * improve bad registry checksum error message
há 6 anos
support for hex v2, multiple repository fetching, private organizations (#1884) * update to hex_core for hex-v2 repo support (#1865) * update to hex_core for hex-v2 repo support This patch adds only single repo hex-v2 support through hex_core. Packages no longer filtered out by buildtool metadata and the package index is updated per-package instead of fetched as one large ets dump. * tell travis to also build hex_core branch * support list of repos for hex packages (#1866) * support list of repos for hex packages repos are defined under the hex key in rebar configs. They can be defined at the top level of a project or globally, but not in profiles and the repos configured in dependencies are also ignored. Searching for packages involves first checking for a match in the local repo index cache, in the order repos are defined. If not found each repo is checked through the hex api for any known versions of the package and the first repo with a version that fits the constraint is used. * add {repos, replace, []} for overriding the global & default repos * add hex auth handling for repos (#1874) auth token are kept in a hex.config file that is modified by the rebar3 hex plugin. Repo names that have a : separating a parent and child are considered organizations. The parent repo's auth will be included with the child. So an organization named hexpm:rebar3_test will include any hexpm auth tokens found in the rebar3_test organization's configuration. * move packages to top level of of hexpm cache dir (#1876) * move packages to top level of of hexpm cache dir * append organization name to parent's repo_url when parsing repos * only eval config scripts and apply overrides once per app (#1879) * only eval config scripts and apply overrides once per app * move new resource behaviour to rebar_resource_v2 and keep v1 * cleanup use of rebar_resource module and unused functions * cleanup error messages and unused code * when discovering apps support mix packages as unbuilt apps (#1882) * use hex_core tarball unpacking support in pkg resource (#1883) * use hex_core tarball unpacking support in pkg resource * ignore etag if package doesn't exist and delete if checksum fails * add back tests for bad package checksums * improve bad registry checksum error message
há 6 anos
  1. -module(rebar_deps_SUITE).
  2. -compile(export_all).
  3. -include_lib("common_test/include/ct.hrl").
  4. -include_lib("eunit/include/eunit.hrl").
  5. all() -> [sub_app_deps, newly_added_dep, newly_added_after_empty_lock, no_deps_empty_lock,
  6. http_proxy_settings, https_proxy_settings,
  7. http_os_proxy_settings, https_os_proxy_settings,
  8. semver_matching_lt, semver_matching_lte, semver_matching_gt,
  9. valid_version, top_override, {group, git}, {group, pkg},
  10. deps_cmd_needs_update_called
  11. ].
  12. groups() ->
  13. [{all, [], [flat, pick_highest_left, pick_highest_right,
  14. pick_smallest1, pick_smallest2,
  15. circular1, circular2, circular_skip]},
  16. {git, [], [{group, all}]},
  17. {pkg, [], [{group, all}]}].
  18. init_per_suite(Config) ->
  19. application:start(meck),
  20. Config.
  21. end_per_suite(_Config) ->
  22. application:stop(meck).
  23. init_per_group(git, Config) ->
  24. [{deps_type, git} | Config];
  25. init_per_group(pkg, Config) ->
  26. [{deps_type, pkg} | Config];
  27. init_per_group(_, Config) ->
  28. Config.
  29. end_per_group(_, Config) ->
  30. Config.
  31. init_per_testcase(valid_version, Config) ->
  32. rebar_test_utils:init_rebar_state(Config);
  33. init_per_testcase(semver_matching_lt, Config) ->
  34. rebar_test_utils:init_rebar_state(Config);
  35. init_per_testcase(semver_matching_lte, Config) ->
  36. rebar_test_utils:init_rebar_state(Config);
  37. init_per_testcase(semver_matching_gt, Config) ->
  38. rebar_test_utils:init_rebar_state(Config);
  39. init_per_testcase(newly_added_after_empty_lock, Config) ->
  40. rebar_test_utils:init_rebar_state(Config);
  41. init_per_testcase(no_deps_empty_lock, Config) ->
  42. rebar_test_utils:init_rebar_state(Config);
  43. init_per_testcase(newly_added_dep, Config) ->
  44. rebar_test_utils:init_rebar_state(Config);
  45. init_per_testcase(sub_app_deps, Config) ->
  46. rebar_test_utils:init_rebar_state(Config);
  47. init_per_testcase(top_override, Config) ->
  48. rebar_test_utils:init_rebar_state(Config);
  49. init_per_testcase(http_proxy_settings, Config) ->
  50. %% Create private rebar.config
  51. Priv = ?config(priv_dir, Config),
  52. GlobalDir = filename:join(Priv, "global"),
  53. GlobalConfigDir = filename:join([GlobalDir, ".config", "rebar3"]),
  54. GlobalConfig = filename:join([GlobalDir, ".config", "rebar3", "rebar.config"]),
  55. meck:new(rebar_dir, [passthrough]),
  56. meck:expect(rebar_dir, global_config, fun() -> GlobalConfig end),
  57. meck:expect(rebar_dir, global_cache_dir, fun(_) -> GlobalDir end),
  58. %% Insert proxy variables into config
  59. rebar_test_utils:create_config(GlobalConfigDir,
  60. [{http_proxy, "http://localhost:1234"}
  61. ]),
  62. rebar_test_utils:init_rebar_state(Config);
  63. init_per_testcase(https_proxy_settings, Config) ->
  64. SupportsHttpsProxy = case erlang:system_info(otp_release) of
  65. "R16"++_ -> true;
  66. "R"++_ -> false;
  67. _ -> true % 17 and up don't have a "R" in the version
  68. end,
  69. if not SupportsHttpsProxy ->
  70. {skip, https_proxy_unsupported_before_R16};
  71. SupportsHttpsProxy ->
  72. %% Create private rebar.config
  73. Priv = ?config(priv_dir, Config),
  74. GlobalDir = filename:join(Priv, "global"),
  75. GlobalConfigDir = filename:join([GlobalDir, ".config", "rebar3"]),
  76. GlobalConfig = filename:join([GlobalDir, ".config", "rebar3", "rebar.config"]),
  77. meck:new(rebar_dir, [passthrough]),
  78. meck:expect(rebar_dir, global_config, fun() -> GlobalConfig end),
  79. meck:expect(rebar_dir, global_cache_dir, fun(_) -> GlobalDir end),
  80. %% Insert proxy variables into config
  81. rebar_test_utils:create_config(GlobalConfigDir,
  82. [{https_proxy, "http://localhost:1234"}
  83. ]),
  84. %% Add a bad value by default to show config overtakes default
  85. os:putenv("https_proxy", "unparseable-garbage"),
  86. rebar_test_utils:init_rebar_state(Config)
  87. end;
  88. init_per_testcase(http_os_proxy_settings, Config) ->
  89. %% Create private rebar.config
  90. Priv = ?config(priv_dir, Config),
  91. GlobalDir = filename:join(Priv, "global"),
  92. GlobalConfigDir = filename:join([GlobalDir, ".config", "rebar3"]),
  93. GlobalConfig = filename:join([GlobalDir, ".config", "rebar3", "rebar.config"]),
  94. meck:new(rebar_dir, [passthrough]),
  95. meck:expect(rebar_dir, global_config, fun() -> GlobalConfig end),
  96. meck:expect(rebar_dir, global_cache_dir, fun(_) -> GlobalDir end),
  97. %% Insert proxy variables into os env, but not config
  98. os:putenv("http_proxy", "http://localhost:1234"),
  99. rebar_test_utils:create_config(GlobalConfigDir, []),
  100. rebar_test_utils:init_rebar_state(Config);
  101. init_per_testcase(https_os_proxy_settings, Config) ->
  102. SupportsHttpsProxy = case erlang:system_info(otp_release) of
  103. "R16"++_ -> true;
  104. "R"++_ -> false;
  105. _ -> true % 17 and up don't have a "R" in the version
  106. end,
  107. if not SupportsHttpsProxy ->
  108. {skip, https_proxy_unsupported_before_R16};
  109. SupportsHttpsProxy ->
  110. %% Create private rebar.config
  111. Priv = ?config(priv_dir, Config),
  112. GlobalDir = filename:join(Priv, "global"),
  113. GlobalConfigDir = filename:join([GlobalDir, ".config", "rebar3"]),
  114. GlobalConfig = filename:join([GlobalDir, ".config", "rebar3", "rebar.config"]),
  115. meck:new(rebar_dir, [passthrough]),
  116. meck:expect(rebar_dir, global_config, fun() -> GlobalConfig end),
  117. meck:expect(rebar_dir, global_cache_dir, fun(_) -> GlobalDir end),
  118. %% Insert proxy variables into os env, not in config
  119. os:putenv("https_proxy", "http://localhost:1234"),
  120. rebar_test_utils:create_config(GlobalConfigDir, []),
  121. rebar_test_utils:init_rebar_state(Config)
  122. end;
  123. init_per_testcase(deps_cmd_needs_update_called, Config) ->
  124. rebar_test_utils:init_rebar_state(Config);
  125. init_per_testcase(Case, Config) ->
  126. {Deps, Warnings, Expect} = deps(Case),
  127. Expected = case Expect of
  128. {ok, List} -> {ok, format_expected_deps(List)};
  129. {error, Reason} -> {error, Reason}
  130. end,
  131. DepsType = ?config(deps_type, Config),
  132. mock_warnings(),
  133. [{expect, Expected},
  134. {warnings, Warnings}
  135. | setup_project(Case, Config, rebar_test_utils:expand_deps(DepsType, Deps))].
  136. end_per_testcase(https_proxy_settings, Config) ->
  137. os:putenv("https_proxy", ""),
  138. meck:unload(rebar_dir),
  139. Config;
  140. end_per_testcase(http_proxy_settings, Config) ->
  141. meck:unload(rebar_dir),
  142. Config;
  143. end_per_testcase(http_os_proxy_settings, Config) ->
  144. os:putenv("http_proxy", ""),
  145. meck:unload(rebar_dir),
  146. Config;
  147. end_per_testcase(https_os_proxy_settings, Config) ->
  148. os:putenv("https_proxy", ""),
  149. meck:unload(rebar_dir),
  150. Config;
  151. end_per_testcase(_, Config) ->
  152. meck:unload(),
  153. Config.
  154. format_expected_deps(Deps) ->
  155. [case Dep of
  156. {N,V} -> {dep, N, V};
  157. N -> {dep, N}
  158. end || Dep <- Deps].
  159. %% format:
  160. %% {Spec,
  161. %% [Warning],
  162. %% {ok, Result} | {error, Reason}}
  163. %%
  164. %% Spec is a list of levelled dependencies of two possible forms:
  165. %% - {"Name", Spec}
  166. %% - {"Name", "Vsn", Spec}
  167. %%
  168. %% Warnings are going to match on mocked ?WARN(...)
  169. %% calls to be evaluated. An empty list means we do not care about
  170. %% warnings, not that no warnings will be printed. This means
  171. %% the list of warning isn't interpreted to be exhaustive, and more
  172. %% warnings may be generated than are listed.
  173. deps(flat) ->
  174. {[{"B", []},
  175. {"C", []}],
  176. [],
  177. {ok, ["B", "C"]}};
  178. deps(pick_highest_left) ->
  179. {[{"B", [{"C", "2.0.0", []}]},
  180. {"C", "1.0.0", []}],
  181. [{"C","2.0.0"}],
  182. {ok, ["B", {"C", "1.0.0"}]}};
  183. deps(pick_highest_right) ->
  184. {[{"B", "1.0.0", []},
  185. {"C", [{"B", "2.0.0", []}]}],
  186. [{"B","2.0.0"}],
  187. {ok, [{"B","1.0.0"}, "C"]}};
  188. deps(pick_smallest1) ->
  189. {[{"B", [{"D", "1.0.0", []}]},
  190. {"C", [{"D", "2.0.0", []}]}],
  191. [{"D","2.0.0"}],
  192. %% we pick D1 because B < C
  193. {ok, ["B","C",{"D","1.0.0"}]}};
  194. deps(pick_smallest2) ->
  195. {[{"C", [{"D", "2.0.0", []}]},
  196. {"B", [{"D", "1.0.0", []}]}],
  197. [{"D","2.0.0"}],
  198. %% we pick D1 because B < C
  199. {ok, ["B","C",{"D","1.0.0"}]}};
  200. deps(circular1) ->
  201. {[{"B", [{"A", []}]}, % A is the top-level app
  202. {"C", []}],
  203. [],
  204. {error, {rebar_prv_install_deps, {cycles, [[<<"A">>,<<"B">>]]}}}};
  205. deps(circular2) ->
  206. {[{"B", [{"C", [{"B", []}]}]},
  207. {"C", []}],
  208. [],
  209. {error, {rebar_prv_install_deps, {cycles, [[<<"B">>,<<"C">>]]}}}};
  210. deps(circular_skip) ->
  211. %% Never spot the circular dep due to being to low in the deps tree
  212. %% in source deps
  213. {[{"B", [{"C", "2.0.0", [{"B", []}]}]},
  214. {"C", "1.0.0", [{"D",[]}]}],
  215. [{"C","2.0.0"}],
  216. {ok, ["B", {"C","1.0.0"}, "D"]}}.
  217. setup_project(Case, Config0, Deps) ->
  218. DepsType = ?config(deps_type, Config0),
  219. %% spread packages across 3 repos randomly
  220. Repos = [<<"test-repo-1">>, <<"test-repo-2">>, <<"hexpm">>],
  221. Config = rebar_test_utils:init_rebar_state(
  222. [{repos, Repos} | Config0],
  223. atom_to_list(Case)++"_"++atom_to_list(DepsType)++"_"
  224. ),
  225. AppDir = ?config(apps, Config),
  226. rebar_test_utils:create_app(AppDir, "A", "0.0.0", [kernel, stdlib]),
  227. TopDeps = rebar_test_utils:top_level_deps(Deps),
  228. RebarConf = rebar_test_utils:create_config(AppDir, [{deps, TopDeps}]),
  229. {SrcDeps, PkgDeps} = rebar_test_utils:flat_deps(Deps),
  230. mock_git_resource:mock([{deps, SrcDeps}]),
  231. mock_pkg_resource:mock([{pkgdeps, PkgDeps}, {repos, Repos}]),
  232. [{rebarconfig, RebarConf} | Config].
  233. mock_warnings() ->
  234. %% just let it do its thing, we check warnings through
  235. %% the call log.
  236. meck:new(rebar_log, [no_link, passthrough]).
  237. mock_rebar_fetch() ->
  238. meck:new(rebar_fetch, [no_link, passthrough]).
  239. %%% TESTS %%%
  240. flat(Config) -> run(Config).
  241. pick_highest_left(Config) -> run(Config).
  242. pick_highest_right(Config) -> run(Config).
  243. pick_smallest1(Config) -> run(Config).
  244. pick_smallest2(Config) -> run(Config).
  245. circular1(Config) -> run(Config).
  246. circular2(Config) -> run(Config).
  247. circular_skip(Config) -> run(Config).
  248. %% Test that a top-level application overtakes dependencies, and
  249. %% works even if said deps do not exist.
  250. top_override(Config) ->
  251. AppDir = ?config(apps, Config),
  252. ct:pal("dir: ~p", [AppDir]),
  253. Name1 = rebar_test_utils:create_random_name("sub_app1_"),
  254. Name2 = rebar_test_utils:create_random_name("sub_app2_"),
  255. SubAppsDir1 = filename:join([AppDir, "apps", Name1]),
  256. SubAppsDir2 = filename:join([AppDir, "apps", Name2]),
  257. Vsn = rebar_test_utils:create_random_vsn(),
  258. rebar_test_utils:create_app(SubAppsDir1, Name1, Vsn, [kernel, stdlib]),
  259. rebar_test_utils:create_app(SubAppsDir2, Name2, Vsn, [kernel, stdlib]),
  260. rebar_test_utils:create_config(
  261. SubAppsDir1,
  262. [{deps, [list_to_atom(Name2)]}]
  263. ),
  264. rebar_test_utils:create_config(
  265. SubAppsDir2,
  266. [{deps, [{list_to_atom(Name1),
  267. {git, "https://example.org", {branch, "master"}}}]}]
  268. ),
  269. rebar_test_utils:run_and_check(
  270. Config, [], ["compile"],
  271. {ok, [{app, Name1}, {app,Name2}]}
  272. ).
  273. %% Test that the deps of project apps that have their own rebar.config
  274. %% are included, but that top level rebar.config deps take precedence
  275. sub_app_deps(Config) ->
  276. AppDir = ?config(apps, Config),
  277. Deps = rebar_test_utils:expand_deps(git, [{"a", "1.0.0", []}
  278. ,{"b", "1.0.0", []}
  279. ,{"b", "2.0.0", []}]),
  280. {SrcDeps, _} = rebar_test_utils:flat_deps(Deps),
  281. mock_git_resource:mock([{deps, SrcDeps}]),
  282. Name = rebar_test_utils:create_random_name("sub_app1_"),
  283. Vsn = rebar_test_utils:create_random_vsn(),
  284. SubAppsDir = filename:join([AppDir, "apps", Name]),
  285. SubDeps = rebar_test_utils:top_level_deps(rebar_test_utils:expand_deps(git, [{"a", "1.0.0", []}
  286. ,{"b", "2.0.0", []}])),
  287. rebar_test_utils:create_app(SubAppsDir, Name, Vsn, [kernel, stdlib]),
  288. rebar_test_utils:create_config(SubAppsDir, [{deps, SubDeps}]),
  289. TopDeps = rebar_test_utils:top_level_deps(rebar_test_utils:expand_deps(git, [{"b", "1.0.0", []}])),
  290. {ok, RebarConfig} = file:consult(rebar_test_utils:create_config(AppDir, [{deps, TopDeps}])),
  291. rebar_test_utils:run_and_check(
  292. Config, RebarConfig, ["compile"],
  293. {ok, [{app, Name}, {dep, "a"}, {dep, "b", "1.0.0"}]}).
  294. %% Newly added dependency after locking
  295. newly_added_dep(Config) ->
  296. AppDir = ?config(apps, Config),
  297. Deps = rebar_test_utils:expand_deps(git, [{"a", "1.0.0", []}
  298. ,{"b", "1.0.0", [{"c", "1.0.0", []}]}
  299. ,{"c", "2.0.0", []}]),
  300. {SrcDeps, _} = rebar_test_utils:flat_deps(Deps),
  301. mock_git_resource:mock([{deps, SrcDeps}]),
  302. Name = rebar_test_utils:create_random_name("app_"),
  303. Vsn = rebar_test_utils:create_random_vsn(),
  304. SubAppsDir = filename:join([AppDir, "apps", Name]),
  305. rebar_test_utils:create_app(SubAppsDir, Name, Vsn, [kernel, stdlib]),
  306. TopDeps = rebar_test_utils:top_level_deps(rebar_test_utils:expand_deps(git, [{"b", "1.0.0", []}])),
  307. {ok, RebarConfig} = file:consult(rebar_test_utils:create_config(AppDir, [{deps, TopDeps}])),
  308. rebar_test_utils:run_and_check(
  309. Config, RebarConfig, ["compile"],
  310. {ok, [{app, Name}, {dep, "b", "1.0.0"}, {dep, "c", "1.0.0"}]}),
  311. %% Add a and c to top level
  312. TopDeps2 = rebar_test_utils:top_level_deps(rebar_test_utils:expand_deps(git, [{"a", "1.0.0", []}
  313. ,{"c", "2.0.0", []}
  314. ,{"b", "1.0.0", []}])),
  315. {ok, RebarConfig2} = file:consult(rebar_test_utils:create_config(AppDir, [{deps, TopDeps2}])),
  316. LockFile = filename:join(AppDir, "rebar.lock"),
  317. RebarConfig3 = rebar_config:merge_locks(RebarConfig2,
  318. rebar_config:consult_lock_file(LockFile)),
  319. %% a should now be installed and c should not change
  320. rebar_test_utils:run_and_check(
  321. Config, RebarConfig3, ["compile"],
  322. {ok, [{app, Name}, {dep, "a"}, {dep, "b", "1.0.0"}, {dep, "c", "1.0.0"}]}).
  323. newly_added_after_empty_lock(Config) ->
  324. AppDir = ?config(apps, Config),
  325. Deps = rebar_test_utils:expand_deps(git, [{"a", "1.0.0", []}]),
  326. {SrcDeps, _} = rebar_test_utils:flat_deps(Deps),
  327. mock_git_resource:mock([{deps, SrcDeps}]),
  328. Name = rebar_test_utils:create_random_name("app_"),
  329. Vsn = rebar_test_utils:create_random_vsn(),
  330. SubAppsDir = filename:join([AppDir, "apps", Name]),
  331. rebar_test_utils:create_app(SubAppsDir, Name, Vsn, [kernel, stdlib]),
  332. TopDeps = rebar_test_utils:top_level_deps(rebar_test_utils:expand_deps(git, [])),
  333. {ok, RebarConfig} = file:consult(rebar_test_utils:create_config(AppDir, [{deps, TopDeps}])),
  334. rebar_test_utils:run_and_check(
  335. Config, RebarConfig, ["compile"],
  336. {ok, []}),
  337. %% Add a and c to top level
  338. TopDeps2 = rebar_test_utils:top_level_deps(rebar_test_utils:expand_deps(git, [{"a", "1.0.0", []}])),
  339. {ok, RebarConfig2} = file:consult(rebar_test_utils:create_config(AppDir, [{deps, TopDeps2}])),
  340. LockFile = filename:join(AppDir, "rebar.lock"),
  341. RebarConfig3 = rebar_config:merge_locks(RebarConfig2,
  342. rebar_config:consult_lock_file(LockFile)),
  343. %% a should now be installed and c should not change
  344. rebar_test_utils:run_and_check(
  345. Config, RebarConfig3, ["compile"],
  346. {ok, [{app, Name}, {dep, "a", "1.0.0"}]}).
  347. no_deps_empty_lock(Config) ->
  348. AppDir = ?config(apps, Config),
  349. Deps = rebar_test_utils:expand_deps(git, []),
  350. mock_git_resource:mock([{deps, Deps}]),
  351. {ok, RebarConfig} = file:consult(rebar_test_utils:create_config(AppDir, [{deps, Deps}])),
  352. rebar_test_utils:run_and_check(
  353. Config, RebarConfig, ["compile"],
  354. {ok, []}),
  355. LockFile = filename:join(AppDir, "rebar.lock"),
  356. %% the lock file should exist
  357. {ok,_} = file:read_file_info(LockFile),
  358. %% and just in case, it should be empty
  359. ?assertEqual([], rebar_config:consult_lock_file(LockFile)),
  360. %% which means that merging that lock file with the current config
  361. %% returns the same config
  362. ?assertEqual(RebarConfig, rebar_config:merge_locks(RebarConfig,
  363. rebar_config:consult_lock_file(LockFile))).
  364. http_proxy_settings(_Config) ->
  365. %% Load config
  366. rebar_utils:set_httpc_options(),
  367. rebar3:init_config(),
  368. %% Assert variable is right
  369. ?assertEqual({ok,{{"localhost", 1234}, []}},
  370. httpc:get_option(proxy, rebar)).
  371. https_proxy_settings(_Config) ->
  372. %% Load config
  373. rebar_utils:set_httpc_options(),
  374. rebar3:init_config(),
  375. %% Assert variable is right
  376. ?assertEqual({ok,{{"localhost", 1234}, []}},
  377. httpc:get_option(https_proxy, rebar)).
  378. http_os_proxy_settings(_Config) ->
  379. %% Load config
  380. rebar_utils:set_httpc_options(),
  381. rebar3:init_config(),
  382. %% Assert variable is right
  383. ?assertEqual({ok,{{"localhost", 1234}, []}},
  384. httpc:get_option(proxy, rebar)).
  385. https_os_proxy_settings(_Config) ->
  386. %% Load config
  387. rebar_utils:set_httpc_options(),
  388. rebar3:init_config(),
  389. %% Assert variable is right
  390. ?assertEqual({ok,{{"localhost", 1234}, []}},
  391. httpc:get_option(https_proxy, rebar)).
  392. semver_matching_lt(_Config) ->
  393. MaxVsn = <<"0.2.0">>,
  394. Vsns = [<<"0.1.7">>, <<"0.1.9">>, <<"0.1.8">>, <<"0.2.0">>, <<"0.2.1">>],
  395. ?assertEqual({ok, <<"0.1.9">>},
  396. rebar_packages:cmpl_(undefined, MaxVsn, Vsns,
  397. fun ec_semver:lt/2)).
  398. semver_matching_lte(_Config) ->
  399. MaxVsn = <<"0.2.0">>,
  400. Vsns = [<<"0.1.7">>, <<"0.1.9">>, <<"0.1.8">>, <<"0.2.0">>, <<"0.2.1">>],
  401. ?assertEqual({ok, <<"0.2.0">>},
  402. rebar_packages:cmpl_(undefined, MaxVsn, Vsns,
  403. fun ec_semver:lte/2)).
  404. semver_matching_gt(_Config) ->
  405. MaxVsn = <<"0.2.0">>,
  406. Vsns = [<<"0.1.7">>, <<"0.1.9">>, <<"0.1.8">>, <<"0.2.0">>, <<"0.2.1">>],
  407. ?assertEqual({ok, <<"0.2.1">>},
  408. rebar_packages:cmp_(undefined, MaxVsn, Vsns,
  409. fun ec_semver:gt/2)).
  410. semver_matching_gte(_Config) ->
  411. MaxVsn = <<"0.2.0">>,
  412. Vsns = [<<"0.1.7">>, <<"0.1.9">>, <<"0.1.8">>, <<"0.2.0">>],
  413. ?assertEqual({ok, <<"0.2.0">>},
  414. rebar_packages:cmp_(undefined, MaxVsn, Vsns,
  415. fun ec_semver:gt/2)).
  416. valid_version(_Config) ->
  417. ?assert(rebar_packages:valid_vsn(<<"0.1">>)),
  418. ?assert(rebar_packages:valid_vsn(<<"0.1.0">>)),
  419. ?assert(rebar_packages:valid_vsn(<<" 0.1.0">>)),
  420. ?assert(rebar_packages:valid_vsn(<<" 0.1.0">>)),
  421. ?assert(rebar_packages:valid_vsn(<<"<0.1">>)),
  422. ?assert(rebar_packages:valid_vsn(<<"<0.1.0">>)),
  423. ?assert(rebar_packages:valid_vsn(<<"< 0.1.0">>)),
  424. ?assert(rebar_packages:valid_vsn(<<"< 0.1.0">>)),
  425. ?assert(rebar_packages:valid_vsn(<<">0.1">>)),
  426. ?assert(rebar_packages:valid_vsn(<<">0.1.0">>)),
  427. ?assert(rebar_packages:valid_vsn(<<"> 0.1.0">>)),
  428. ?assert(rebar_packages:valid_vsn(<<"> 0.1.0">>)),
  429. ?assert(rebar_packages:valid_vsn(<<"<=0.1">>)),
  430. ?assert(rebar_packages:valid_vsn(<<"<=0.1.0">>)),
  431. ?assert(rebar_packages:valid_vsn(<<"<= 0.1.0">>)),
  432. ?assert(rebar_packages:valid_vsn(<<"<= 0.1.0">>)),
  433. ?assert(rebar_packages:valid_vsn(<<">=0.1">>)),
  434. ?assert(rebar_packages:valid_vsn(<<">=0.1.0">>)),
  435. ?assert(rebar_packages:valid_vsn(<<">= 0.1.0">>)),
  436. ?assert(rebar_packages:valid_vsn(<<">= 0.1.0">>)),
  437. ?assert(rebar_packages:valid_vsn(<<"==0.1">>)),
  438. ?assert(rebar_packages:valid_vsn(<<"==0.1.0">>)),
  439. ?assert(rebar_packages:valid_vsn(<<"== 0.1.0">>)),
  440. ?assert(rebar_packages:valid_vsn(<<"== 0.1.0">>)),
  441. ?assert(rebar_packages:valid_vsn(<<"~>0.1">>)),
  442. ?assert(rebar_packages:valid_vsn(<<"~>0.1.0">>)),
  443. ?assert(rebar_packages:valid_vsn(<<"~> 0.1.0">>)),
  444. ?assert(rebar_packages:valid_vsn(<<"~> 0.1.0">>)),
  445. ?assertNot(rebar_packages:valid_vsn(<<"> 0.1.0 and < 0.2.0">>)),
  446. ok.
  447. run(Config) ->
  448. {ok, RebarConfig} = file:consult(?config(rebarconfig, Config)),
  449. rebar_test_utils:run_and_check(
  450. Config, RebarConfig, ["install_deps"], ?config(expect, Config)
  451. ),
  452. check_warnings(warning_calls(), ?config(warnings, Config), ?config(deps_type, Config)).
  453. deps_cmd_needs_update_called(Config) ->
  454. mock_rebar_fetch(),
  455. AppDir = ?config(apps, Config),
  456. Deps = rebar_test_utils:expand_deps(git, [{"a", "1.0.0", []}
  457. ,{"b", "1.0.0", [{"c", "1.0.0", []}]}
  458. ,{"c", "2.0.0", []}]),
  459. {SrcDeps, _} = rebar_test_utils:flat_deps(Deps),
  460. mock_git_resource:mock([{deps, SrcDeps}]),
  461. Name = rebar_test_utils:create_random_name("app_"),
  462. Vsn = rebar_test_utils:create_random_vsn(),
  463. SubAppsDir = filename:join([AppDir, "apps", Name]),
  464. rebar_test_utils:create_app(SubAppsDir, Name, Vsn, [kernel, stdlib]),
  465. TopDeps = rebar_test_utils:top_level_deps(
  466. rebar_test_utils:expand_deps(git, [{"b", "1.0.0", []}])),
  467. {ok, RebarConfig} = file:consult(rebar_test_utils:create_config(AppDir, [{deps, TopDeps}])),
  468. rebar_test_utils:run_and_check(Config, RebarConfig, ["deps"], {ok, []}),
  469. [<<"b">>] = rebar_fetch_needs_update_calls_sorted(),
  470. %% Add c to top level
  471. TopDeps2 = rebar_test_utils:top_level_deps(rebar_test_utils:expand_deps(git, [{"c", "2.0.0", []}
  472. ,{"b", "1.0.0", []}])),
  473. {ok, RebarConfig2} = file:consult(rebar_test_utils:create_config(AppDir, [{deps, TopDeps2}])),
  474. rebar_test_utils:run_and_check(Config, RebarConfig2, ["deps"], {ok, []}),
  475. %% Only top level deps are checked for updates
  476. [<<"b">>, <<"b">>, <<"c">>] = rebar_fetch_needs_update_calls_sorted(),
  477. %% Lock deps
  478. rebar_test_utils:run_and_check(Config, RebarConfig2, ["lock"], {ok, []}),
  479. NeedsUpdate1 = rebar_fetch_needs_update_calls_sorted(),
  480. %% Switch c for a as top level deps
  481. TopDeps3 = rebar_test_utils:top_level_deps(rebar_test_utils:expand_deps(git, [{"a", "1.0.0", []}
  482. ,{"b", "1.0.0", []}])),
  483. {ok, RebarConfig3} = file:consult(rebar_test_utils:create_config(AppDir, [{deps, TopDeps3}])),
  484. LockFile = filename:join(AppDir, "rebar.lock"),
  485. RebarConfig4 = rebar_config:merge_locks(RebarConfig3,
  486. rebar_config:consult_lock_file(LockFile)),
  487. rebar_test_utils:run_and_check(Config, RebarConfig4, ["deps"], {ok, []}),
  488. NeedsUpdate2 = lists:subtract(rebar_fetch_needs_update_calls_sorted(), NeedsUpdate1),
  489. %% B and C from lock file + install_deps and A, B and C from 'deps'
  490. [<<"a">>, <<"b">>, <<"b">>, <<"c">>, <<"c">>] = NeedsUpdate2.
  491. rebar_fetch_needs_update_calls_sorted() ->
  492. History = meck:history(rebar_fetch),
  493. DepsNames = [rebar_app_info:name(Dep)
  494. || {_, {rebar_fetch, needs_update, [Dep, _]}, _} <- History],
  495. lists:sort(DepsNames).
  496. warning_calls() ->
  497. History = meck:history(rebar_log),
  498. [{Str, Args} || {_, {rebar_log, log, [warn, Str, Args]}, _} <- History].
  499. check_warnings(_, [], _) ->
  500. ok;
  501. check_warnings(Warns, [{Name, Vsn} | Rest], Type) ->
  502. ct:pal("Checking for warning ~p in ~p", [{Name,Vsn},Warns]),
  503. ?assert(in_warnings(Type, Warns, Name, Vsn)),
  504. check_warnings(Warns, Rest, Type).
  505. in_warnings(git, Warns, NameRaw, VsnRaw) ->
  506. Name = iolist_to_binary(NameRaw),
  507. Vsn = iolist_to_binary([$",VsnRaw,$"]),
  508. 1 =< length([1 || {_, [[AppName, $\s,$(,$f,$r,$o,$m,$\s,[${,["git",$,, _URL, $,,[${,["tag",$,, AppVsn], $}]],$}],$)]]} <- Warns,
  509. iolist_to_binary(AppName) =:= Name,
  510. iolist_to_binary(AppVsn) =:= Vsn]);
  511. in_warnings(pkg, Warns, NameRaw, VsnRaw) ->
  512. Name = iolist_to_binary(NameRaw),
  513. Vsn = iolist_to_binary(VsnRaw),
  514. 1 =< length([1 || {_, [[AppName, $\s,$v, AppVsn]]} <- Warns,
  515. iolist_to_binary(AppName) =:= Name,
  516. iolist_to_binary(AppVsn) =:= Vsn]).