bundler 2.2.29 → 2.5.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +1129 -4
- data/README.md +4 -8
- data/bundler.gemspec +11 -11
- data/exe/bundle +5 -26
- data/exe/bundler +1 -1
- data/lib/bundler/.document +1 -0
- data/lib/bundler/build_metadata.rb +4 -4
- data/lib/bundler/capistrano.rb +1 -1
- data/lib/bundler/checksum.rb +254 -0
- data/lib/bundler/ci_detector.rb +75 -0
- data/lib/bundler/cli/add.rb +4 -4
- data/lib/bundler/cli/binstubs.rb +10 -6
- data/lib/bundler/cli/cache.rb +1 -1
- data/lib/bundler/cli/check.rb +3 -3
- data/lib/bundler/cli/common.rb +13 -3
- data/lib/bundler/cli/config.rb +18 -8
- data/lib/bundler/cli/console.rb +5 -4
- data/lib/bundler/cli/doctor.rb +12 -5
- data/lib/bundler/cli/exec.rb +1 -1
- data/lib/bundler/cli/fund.rb +1 -1
- data/lib/bundler/cli/gem.rb +141 -48
- data/lib/bundler/cli/info.rb +27 -17
- data/lib/bundler/cli/init.rb +6 -2
- data/lib/bundler/cli/install.rb +22 -39
- data/lib/bundler/cli/issue.rb +5 -4
- data/lib/bundler/cli/lock.rb +36 -29
- data/lib/bundler/cli/open.rb +9 -9
- data/lib/bundler/cli/outdated.rb +19 -12
- data/lib/bundler/cli/platform.rb +8 -6
- data/lib/bundler/cli/plugin.rb +9 -15
- data/lib/bundler/cli/pristine.rb +38 -30
- data/lib/bundler/cli/show.rb +3 -3
- data/lib/bundler/cli/update.rb +12 -7
- data/lib/bundler/cli/viz.rb +1 -1
- data/lib/bundler/cli.rb +266 -285
- data/lib/bundler/compact_index_client/cache.rb +53 -67
- data/lib/bundler/compact_index_client/cache_file.rb +153 -0
- data/lib/bundler/compact_index_client/gem_parser.rb +7 -3
- data/lib/bundler/compact_index_client/parser.rb +84 -0
- data/lib/bundler/compact_index_client/updater.rb +83 -76
- data/lib/bundler/compact_index_client.rb +59 -87
- data/lib/bundler/constants.rb +9 -2
- data/lib/bundler/current_ruby.rb +12 -16
- data/lib/bundler/definition.rb +509 -319
- data/lib/bundler/dependency.rb +33 -71
- data/lib/bundler/digest.rb +71 -0
- data/lib/bundler/dsl.rb +88 -69
- data/lib/bundler/endpoint_specification.rb +32 -15
- data/lib/bundler/env.rb +5 -7
- data/lib/bundler/environment_preserver.rb +8 -22
- data/lib/bundler/errors.rb +101 -13
- data/lib/bundler/feature_flag.rb +0 -2
- data/lib/bundler/fetcher/base.rb +11 -11
- data/lib/bundler/fetcher/compact_index.rb +32 -52
- data/lib/bundler/fetcher/dependency.rb +3 -7
- data/lib/bundler/fetcher/downloader.rb +17 -16
- data/lib/bundler/fetcher/gem_remote_fetcher.rb +16 -0
- data/lib/bundler/fetcher/index.rb +2 -29
- data/lib/bundler/fetcher.rb +87 -79
- data/lib/bundler/force_platform.rb +18 -0
- data/lib/bundler/friendly_errors.rb +29 -40
- data/lib/bundler/gem_helper.rb +11 -23
- data/lib/bundler/gem_helpers.rb +30 -6
- data/lib/bundler/gem_version_promoter.rb +68 -109
- data/lib/bundler/graph.rb +9 -9
- data/lib/bundler/index.rb +71 -79
- data/lib/bundler/injector.rb +23 -11
- data/lib/bundler/inline.rb +11 -23
- data/lib/bundler/installer/gem_installer.rb +18 -11
- data/lib/bundler/installer/parallel_installer.rb +17 -65
- data/lib/bundler/installer/standalone.rb +56 -15
- data/lib/bundler/installer.rb +35 -61
- data/lib/bundler/lazy_specification.rb +92 -61
- data/lib/bundler/lockfile_generator.rb +12 -3
- data/lib/bundler/lockfile_parser.rb +137 -70
- data/lib/bundler/man/bundle-add.1 +19 -26
- data/lib/bundler/man/bundle-add.1.ronn +16 -4
- data/lib/bundler/man/bundle-binstubs.1 +4 -16
- data/lib/bundler/man/bundle-cache.1 +9 -24
- data/lib/bundler/man/bundle-cache.1.ronn +9 -2
- data/lib/bundler/man/bundle-check.1 +5 -12
- data/lib/bundler/man/bundle-check.1.ronn +3 -0
- data/lib/bundler/man/bundle-clean.1 +4 -11
- data/lib/bundler/man/bundle-clean.1.ronn +1 -1
- data/lib/bundler/man/bundle-config.1 +47 -224
- data/lib/bundler/man/bundle-config.1.ronn +40 -28
- data/lib/bundler/man/bundle-console.1 +35 -0
- data/lib/bundler/man/bundle-console.1.ronn +44 -0
- data/lib/bundler/man/bundle-doctor.1 +4 -18
- data/lib/bundler/man/bundle-exec.1 +16 -77
- data/lib/bundler/man/bundle-exec.1.ronn +8 -9
- data/lib/bundler/man/bundle-gem.1 +45 -72
- data/lib/bundler/man/bundle-gem.1.ronn +32 -5
- data/lib/bundler/man/bundle-help.1 +9 -0
- data/lib/bundler/man/bundle-help.1.ronn +12 -0
- data/lib/bundler/man/bundle-info.1 +5 -11
- data/lib/bundler/man/bundle-info.1.ronn +3 -3
- data/lib/bundler/man/bundle-init.1 +6 -11
- data/lib/bundler/man/bundle-init.1.ronn +2 -0
- data/lib/bundler/man/bundle-inject.1 +8 -18
- data/lib/bundler/man/bundle-inject.1.ronn +3 -1
- data/lib/bundler/man/bundle-install.1 +32 -155
- data/lib/bundler/man/bundle-install.1.ronn +11 -33
- data/lib/bundler/man/bundle-list.1 +4 -19
- data/lib/bundler/man/bundle-lock.1 +5 -29
- data/lib/bundler/man/bundle-open.1 +18 -18
- data/lib/bundler/man/bundle-open.1.ronn +9 -1
- data/lib/bundler/man/bundle-outdated.1 +17 -72
- data/lib/bundler/man/bundle-outdated.1.ronn +13 -18
- data/lib/bundler/man/bundle-platform.1 +16 -28
- data/lib/bundler/man/bundle-platform.1.ronn +14 -7
- data/lib/bundler/man/bundle-plugin.1 +58 -0
- data/lib/bundler/man/bundle-plugin.1.ronn +63 -0
- data/lib/bundler/man/bundle-pristine.1 +5 -16
- data/lib/bundler/man/bundle-remove.1 +4 -14
- data/lib/bundler/man/bundle-show.1 +3 -10
- data/lib/bundler/man/bundle-update.1 +19 -138
- data/lib/bundler/man/bundle-update.1.ronn +2 -1
- data/lib/bundler/man/bundle-version.1 +22 -0
- data/lib/bundler/man/bundle-version.1.ronn +24 -0
- data/lib/bundler/man/bundle-viz.1 +6 -15
- data/lib/bundler/man/bundle-viz.1.ronn +2 -0
- data/lib/bundler/man/bundle.1 +17 -51
- data/lib/bundler/man/bundle.1.ronn +12 -7
- data/lib/bundler/man/gemfile.5 +130 -346
- data/lib/bundler/man/gemfile.5.ronn +121 -86
- data/lib/bundler/man/index.txt +4 -0
- data/lib/bundler/match_metadata.rb +17 -0
- data/lib/bundler/match_platform.rb +1 -2
- data/lib/bundler/match_remote_metadata.rb +29 -0
- data/lib/bundler/mirror.rb +8 -10
- data/lib/bundler/plugin/api/source.rb +9 -13
- data/lib/bundler/plugin/index.rb +13 -5
- data/lib/bundler/plugin/installer/git.rb +0 -4
- data/lib/bundler/plugin/installer/path.rb +18 -0
- data/lib/bundler/plugin/installer/rubygems.rb +0 -8
- data/lib/bundler/plugin/installer.rb +42 -19
- data/lib/bundler/plugin/source_list.rb +4 -4
- data/lib/bundler/plugin.rb +16 -7
- data/lib/bundler/process_lock.rb +1 -1
- data/lib/bundler/remote_specification.rb +11 -5
- data/lib/bundler/resolver/base.rb +111 -0
- data/lib/bundler/resolver/candidate.rb +82 -0
- data/lib/bundler/resolver/incompatibility.rb +15 -0
- data/lib/bundler/resolver/package.rb +81 -0
- data/lib/bundler/resolver/root.rb +25 -0
- data/lib/bundler/resolver/spec_group.rb +53 -66
- data/lib/bundler/resolver.rb +419 -307
- data/lib/bundler/retry.rb +1 -1
- data/lib/bundler/ruby_dsl.rb +42 -7
- data/lib/bundler/ruby_version.rb +16 -22
- data/lib/bundler/rubygems_ext.rb +250 -64
- data/lib/bundler/rubygems_gem_installer.rb +90 -64
- data/lib/bundler/rubygems_integration.rb +81 -190
- data/lib/bundler/runtime.rb +8 -13
- data/lib/bundler/safe_marshal.rb +31 -0
- data/lib/bundler/self_manager.rb +206 -0
- data/lib/bundler/settings.rb +139 -57
- data/lib/bundler/setup.rb +13 -1
- data/lib/bundler/shared_helpers.rb +67 -36
- data/lib/bundler/source/git/git_proxy.rb +285 -82
- data/lib/bundler/source/git.rb +81 -41
- data/lib/bundler/source/metadata.rb +17 -16
- data/lib/bundler/source/path/installer.rb +1 -22
- data/lib/bundler/source/path.rb +13 -25
- data/lib/bundler/source/rubygems/remote.rb +1 -1
- data/lib/bundler/source/rubygems.rb +164 -234
- data/lib/bundler/source/rubygems_aggregate.rb +1 -1
- data/lib/bundler/source.rb +7 -6
- data/lib/bundler/source_list.rb +40 -32
- data/lib/bundler/source_map.rb +15 -2
- data/lib/bundler/spec_set.rb +156 -46
- data/lib/bundler/stub_specification.rb +18 -5
- data/lib/bundler/templates/Executable +3 -5
- data/lib/bundler/templates/Executable.bundler +7 -12
- data/lib/bundler/templates/Executable.standalone +4 -4
- data/lib/bundler/templates/Gemfile +0 -2
- data/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt +77 -29
- data/lib/bundler/templates/newgem/Cargo.toml.tt +7 -0
- data/lib/bundler/templates/newgem/Gemfile.tt +8 -2
- data/lib/bundler/templates/newgem/README.md.tt +7 -11
- data/lib/bundler/templates/newgem/Rakefile.tt +28 -4
- data/lib/bundler/templates/newgem/bin/console.tt +0 -4
- data/lib/bundler/templates/newgem/circleci/config.yml.tt +12 -0
- data/lib/bundler/templates/newgem/ext/newgem/Cargo.toml.tt +15 -0
- data/lib/bundler/templates/newgem/ext/newgem/extconf-c.rb.tt +10 -0
- data/lib/bundler/templates/newgem/ext/newgem/extconf-rust.rb.tt +6 -0
- data/lib/bundler/templates/newgem/ext/newgem/newgem.c.tt +1 -1
- data/lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt +12 -0
- data/lib/bundler/templates/newgem/github/workflows/main.yml.tt +13 -3
- data/lib/bundler/templates/newgem/gitignore.tt +3 -0
- data/lib/bundler/templates/newgem/gitlab-ci.yml.tt +13 -4
- data/lib/bundler/templates/newgem/newgem.gemspec.tt +25 -17
- data/lib/bundler/templates/newgem/rubocop.yml.tt +0 -5
- data/lib/bundler/templates/newgem/sig/newgem.rbs.tt +8 -0
- data/lib/bundler/templates/newgem/standard.yml.tt +3 -0
- data/lib/bundler/templates/newgem/test/minitest/{newgem_test.rb.tt → test_newgem.rb.tt} +1 -1
- data/lib/bundler/ui/rg_proxy.rb +1 -1
- data/lib/bundler/ui/shell.rb +38 -15
- data/lib/bundler/ui/silent.rb +21 -5
- data/lib/bundler/uri_credentials_filter.rb +2 -2
- data/lib/bundler/uri_normalizer.rb +23 -0
- data/lib/bundler/vendor/.document +1 -0
- data/lib/bundler/vendor/connection_pool/.document +1 -0
- data/lib/bundler/vendor/connection_pool/LICENSE +20 -0
- data/lib/bundler/vendor/connection_pool/lib/connection_pool/timed_stack.rb +19 -21
- data/lib/bundler/vendor/connection_pool/lib/connection_pool/version.rb +1 -1
- data/lib/bundler/vendor/connection_pool/lib/connection_pool/wrapper.rb +56 -0
- data/lib/bundler/vendor/connection_pool/lib/connection_pool.rb +92 -78
- data/lib/bundler/vendor/fileutils/.document +1 -0
- data/lib/bundler/vendor/fileutils/LICENSE.txt +22 -0
- data/lib/bundler/vendor/fileutils/lib/fileutils.rb +1340 -410
- data/lib/bundler/vendor/net-http-persistent/.document +1 -0
- data/lib/bundler/vendor/net-http-persistent/README.rdoc +82 -0
- data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/connection.rb +4 -3
- data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/pool.rb +23 -11
- data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/timed_stack_multi.rb +1 -1
- data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +57 -57
- data/lib/bundler/vendor/pub_grub/.document +1 -0
- data/lib/bundler/vendor/pub_grub/LICENSE.txt +21 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/assignment.rb +20 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/basic_package_source.rb +189 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/failure_writer.rb +182 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/incompatibility.rb +150 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/package.rb +43 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/partial_solution.rb +121 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/rubygems.rb +45 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/solve_failure.rb +19 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/static_package_source.rb +61 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/term.rb +105 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/version.rb +3 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_constraint.rb +129 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_range.rb +411 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_solver.rb +248 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_union.rb +178 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub.rb +31 -0
- data/lib/bundler/vendor/thor/.document +1 -0
- data/lib/bundler/vendor/thor/LICENSE.md +20 -0
- data/lib/bundler/vendor/thor/lib/thor/actions/create_file.rb +3 -2
- data/lib/bundler/vendor/thor/lib/thor/actions/directory.rb +1 -1
- data/lib/bundler/vendor/thor/lib/thor/actions/empty_directory.rb +1 -1
- data/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +12 -14
- data/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb +16 -6
- data/lib/bundler/vendor/thor/lib/thor/actions.rb +21 -17
- data/lib/bundler/vendor/thor/lib/thor/base.rb +140 -14
- data/lib/bundler/vendor/thor/lib/thor/command.rb +13 -4
- data/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +10 -0
- data/lib/bundler/vendor/thor/lib/thor/error.rb +16 -20
- data/lib/bundler/vendor/thor/lib/thor/group.rb +1 -1
- data/lib/bundler/vendor/thor/lib/thor/invocation.rb +1 -1
- data/lib/bundler/vendor/thor/lib/thor/nested_context.rb +2 -2
- data/lib/bundler/vendor/thor/lib/thor/parser/argument.rb +20 -1
- data/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb +33 -17
- data/lib/bundler/vendor/thor/lib/thor/parser/option.rb +27 -8
- data/lib/bundler/vendor/thor/lib/thor/parser/options.rb +63 -7
- data/lib/bundler/vendor/thor/lib/thor/rake_compat.rb +2 -2
- data/lib/bundler/vendor/thor/lib/thor/runner.rb +40 -30
- data/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +48 -154
- data/lib/bundler/vendor/thor/lib/thor/shell/color.rb +1 -46
- data/lib/bundler/vendor/thor/lib/thor/shell/column_printer.rb +29 -0
- data/lib/bundler/vendor/thor/lib/thor/shell/html.rb +0 -45
- data/lib/bundler/vendor/thor/lib/thor/shell/table_printer.rb +134 -0
- data/lib/bundler/vendor/thor/lib/thor/shell/terminal.rb +42 -0
- data/lib/bundler/vendor/thor/lib/thor/shell/wrapped_printer.rb +38 -0
- data/lib/bundler/vendor/thor/lib/thor/shell.rb +2 -2
- data/lib/bundler/vendor/thor/lib/thor/util.rb +9 -8
- data/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
- data/lib/bundler/vendor/thor/lib/thor.rb +155 -8
- data/lib/bundler/vendor/tsort/.document +1 -0
- data/lib/bundler/vendor/tsort/LICENSE.txt +22 -0
- data/lib/bundler/vendor/tsort/lib/tsort.rb +455 -0
- data/lib/bundler/vendor/uri/.document +1 -0
- data/lib/bundler/vendor/uri/LICENSE.txt +22 -0
- data/lib/bundler/vendor/uri/lib/uri/common.rb +316 -207
- data/lib/bundler/vendor/uri/lib/uri/file.rb +7 -1
- data/lib/bundler/vendor/uri/lib/uri/ftp.rb +2 -2
- data/lib/bundler/vendor/uri/lib/uri/generic.rb +33 -13
- data/lib/bundler/vendor/uri/lib/uri/http.rb +40 -3
- data/lib/bundler/vendor/uri/lib/uri/https.rb +2 -2
- data/lib/bundler/vendor/uri/lib/uri/ldap.rb +2 -2
- data/lib/bundler/vendor/uri/lib/uri/ldaps.rb +2 -1
- data/lib/bundler/vendor/uri/lib/uri/mailto.rb +2 -3
- data/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb +16 -23
- data/lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb +105 -47
- data/lib/bundler/vendor/uri/lib/uri/version.rb +1 -1
- data/lib/bundler/vendor/uri/lib/uri/ws.rb +83 -0
- data/lib/bundler/vendor/uri/lib/uri/wss.rb +23 -0
- data/lib/bundler/vendor/uri/lib/uri.rb +3 -3
- data/lib/bundler/vendored_net_http.rb +23 -0
- data/lib/bundler/vendored_persistent.rb +0 -36
- data/lib/bundler/{vendored_molinillo.rb → vendored_pub_grub.rb} +1 -1
- data/lib/bundler/vendored_timeout.rb +12 -0
- data/lib/bundler/{vendored_tmpdir.rb → vendored_tsort.rb} +1 -1
- data/lib/bundler/vendored_uri.rb +18 -1
- data/lib/bundler/version.rb +5 -1
- data/lib/bundler/vlad.rb +1 -1
- data/lib/bundler/worker.rb +7 -9
- data/lib/bundler/yaml_serializer.rb +21 -12
- data/lib/bundler.rb +114 -121
- metadata +87 -41
- data/lib/bundler/dep_proxy.rb +0 -55
- data/lib/bundler/gemdeps.rb +0 -29
- data/lib/bundler/psyched_yaml.rb +0 -22
- data/lib/bundler/templates/gems.rb +0 -8
- data/lib/bundler/templates/newgem/ext/newgem/extconf.rb.tt +0 -5
- data/lib/bundler/templates/newgem/travis.yml.tt +0 -6
- data/lib/bundler/vendor/connection_pool/lib/connection_pool/monotonic_time.rb +0 -66
- data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/resolution_state.rb +0 -57
- data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/specification_provider.rb +0 -88
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/action.rb +0 -36
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb +0 -66
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_vertex.rb +0 -62
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/delete_edge.rb +0 -63
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb +0 -61
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/log.rb +0 -126
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/set_payload.rb +0 -46
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/tag.rb +0 -36
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb +0 -164
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +0 -255
- data/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb +0 -143
- data/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb +0 -6
- data/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb +0 -112
- data/lib/bundler/vendor/molinillo/lib/molinillo/modules/ui.rb +0 -67
- data/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb +0 -839
- data/lib/bundler/vendor/molinillo/lib/molinillo/resolver.rb +0 -46
- data/lib/bundler/vendor/molinillo/lib/molinillo/state.rb +0 -58
- data/lib/bundler/vendor/molinillo/lib/molinillo.rb +0 -11
- data/lib/bundler/vendor/tmpdir/lib/tmpdir.rb +0 -154
- data/lib/bundler/version_ranges.rb +0 -122
@@ -0,0 +1,411 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Bundler::PubGrub
|
4
|
+
class VersionRange
|
5
|
+
attr_reader :min, :max, :include_min, :include_max
|
6
|
+
|
7
|
+
alias_method :include_min?, :include_min
|
8
|
+
alias_method :include_max?, :include_max
|
9
|
+
|
10
|
+
class Empty < VersionRange
|
11
|
+
undef_method :min, :max
|
12
|
+
undef_method :include_min, :include_min?
|
13
|
+
undef_method :include_max, :include_max?
|
14
|
+
|
15
|
+
def initialize
|
16
|
+
end
|
17
|
+
|
18
|
+
def empty?
|
19
|
+
true
|
20
|
+
end
|
21
|
+
|
22
|
+
def eql?(other)
|
23
|
+
other.empty?
|
24
|
+
end
|
25
|
+
|
26
|
+
def hash
|
27
|
+
[].hash
|
28
|
+
end
|
29
|
+
|
30
|
+
def intersects?(_)
|
31
|
+
false
|
32
|
+
end
|
33
|
+
|
34
|
+
def intersect(other)
|
35
|
+
self
|
36
|
+
end
|
37
|
+
|
38
|
+
def allows_all?(other)
|
39
|
+
other.empty?
|
40
|
+
end
|
41
|
+
|
42
|
+
def include?(_)
|
43
|
+
false
|
44
|
+
end
|
45
|
+
|
46
|
+
def any?
|
47
|
+
false
|
48
|
+
end
|
49
|
+
|
50
|
+
def to_s
|
51
|
+
"(no versions)"
|
52
|
+
end
|
53
|
+
|
54
|
+
def ==(other)
|
55
|
+
other.class == self.class
|
56
|
+
end
|
57
|
+
|
58
|
+
def invert
|
59
|
+
VersionRange.any
|
60
|
+
end
|
61
|
+
|
62
|
+
def select_versions(_)
|
63
|
+
[]
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
EMPTY = Empty.new
|
68
|
+
Empty.singleton_class.undef_method(:new)
|
69
|
+
|
70
|
+
def self.empty
|
71
|
+
EMPTY
|
72
|
+
end
|
73
|
+
|
74
|
+
def self.any
|
75
|
+
new
|
76
|
+
end
|
77
|
+
|
78
|
+
def initialize(min: nil, max: nil, include_min: false, include_max: false, name: nil)
|
79
|
+
@min = min
|
80
|
+
@max = max
|
81
|
+
@include_min = include_min
|
82
|
+
@include_max = include_max
|
83
|
+
@name = name
|
84
|
+
end
|
85
|
+
|
86
|
+
def hash
|
87
|
+
@hash ||= min.hash ^ max.hash ^ include_min.hash ^ include_max.hash
|
88
|
+
end
|
89
|
+
|
90
|
+
def eql?(other)
|
91
|
+
if other.is_a?(VersionRange)
|
92
|
+
!other.empty? &&
|
93
|
+
min.eql?(other.min) &&
|
94
|
+
max.eql?(other.max) &&
|
95
|
+
include_min.eql?(other.include_min) &&
|
96
|
+
include_max.eql?(other.include_max)
|
97
|
+
else
|
98
|
+
ranges.eql?(other.ranges)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
def ranges
|
103
|
+
[self]
|
104
|
+
end
|
105
|
+
|
106
|
+
def include?(version)
|
107
|
+
compare_version(version) == 0
|
108
|
+
end
|
109
|
+
|
110
|
+
# Partitions passed versions into [lower, within, higher]
|
111
|
+
#
|
112
|
+
# versions must be sorted
|
113
|
+
def partition_versions(versions)
|
114
|
+
min_index =
|
115
|
+
if !min || versions.empty?
|
116
|
+
0
|
117
|
+
elsif include_min?
|
118
|
+
(0..versions.size).bsearch { |i| versions[i].nil? || versions[i] >= min }
|
119
|
+
else
|
120
|
+
(0..versions.size).bsearch { |i| versions[i].nil? || versions[i] > min }
|
121
|
+
end
|
122
|
+
|
123
|
+
lower = versions.slice(0, min_index)
|
124
|
+
versions = versions.slice(min_index, versions.size)
|
125
|
+
|
126
|
+
max_index =
|
127
|
+
if !max || versions.empty?
|
128
|
+
versions.size
|
129
|
+
elsif include_max?
|
130
|
+
(0..versions.size).bsearch { |i| versions[i].nil? || versions[i] > max }
|
131
|
+
else
|
132
|
+
(0..versions.size).bsearch { |i| versions[i].nil? || versions[i] >= max }
|
133
|
+
end
|
134
|
+
|
135
|
+
[
|
136
|
+
lower,
|
137
|
+
versions.slice(0, max_index),
|
138
|
+
versions.slice(max_index, versions.size)
|
139
|
+
]
|
140
|
+
end
|
141
|
+
|
142
|
+
# Returns versions which are included by this range.
|
143
|
+
#
|
144
|
+
# versions must be sorted
|
145
|
+
def select_versions(versions)
|
146
|
+
return versions if any?
|
147
|
+
|
148
|
+
partition_versions(versions)[1]
|
149
|
+
end
|
150
|
+
|
151
|
+
def compare_version(version)
|
152
|
+
if min
|
153
|
+
case version <=> min
|
154
|
+
when -1
|
155
|
+
return -1
|
156
|
+
when 0
|
157
|
+
return -1 if !include_min
|
158
|
+
when 1
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
if max
|
163
|
+
case version <=> max
|
164
|
+
when -1
|
165
|
+
when 0
|
166
|
+
return 1 if !include_max
|
167
|
+
when 1
|
168
|
+
return 1
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
0
|
173
|
+
end
|
174
|
+
|
175
|
+
def strictly_lower?(other)
|
176
|
+
return false if !max || !other.min
|
177
|
+
|
178
|
+
case max <=> other.min
|
179
|
+
when 0
|
180
|
+
!include_max || !other.include_min
|
181
|
+
when -1
|
182
|
+
true
|
183
|
+
when 1
|
184
|
+
false
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
def strictly_higher?(other)
|
189
|
+
other.strictly_lower?(self)
|
190
|
+
end
|
191
|
+
|
192
|
+
def intersects?(other)
|
193
|
+
return false if other.empty?
|
194
|
+
return other.intersects?(self) if other.is_a?(VersionUnion)
|
195
|
+
!strictly_lower?(other) && !strictly_higher?(other)
|
196
|
+
end
|
197
|
+
alias_method :allows_any?, :intersects?
|
198
|
+
|
199
|
+
def intersect(other)
|
200
|
+
return other if other.empty?
|
201
|
+
return other.intersect(self) if other.is_a?(VersionUnion)
|
202
|
+
|
203
|
+
min_range =
|
204
|
+
if !min
|
205
|
+
other
|
206
|
+
elsif !other.min
|
207
|
+
self
|
208
|
+
else
|
209
|
+
case min <=> other.min
|
210
|
+
when 0
|
211
|
+
include_min ? other : self
|
212
|
+
when -1
|
213
|
+
other
|
214
|
+
when 1
|
215
|
+
self
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
max_range =
|
220
|
+
if !max
|
221
|
+
other
|
222
|
+
elsif !other.max
|
223
|
+
self
|
224
|
+
else
|
225
|
+
case max <=> other.max
|
226
|
+
when 0
|
227
|
+
include_max ? other : self
|
228
|
+
when -1
|
229
|
+
self
|
230
|
+
when 1
|
231
|
+
other
|
232
|
+
end
|
233
|
+
end
|
234
|
+
|
235
|
+
if !min_range.equal?(max_range) && min_range.min && max_range.max
|
236
|
+
case min_range.min <=> max_range.max
|
237
|
+
when -1
|
238
|
+
when 0
|
239
|
+
if !min_range.include_min || !max_range.include_max
|
240
|
+
return EMPTY
|
241
|
+
end
|
242
|
+
when 1
|
243
|
+
return EMPTY
|
244
|
+
end
|
245
|
+
end
|
246
|
+
|
247
|
+
VersionRange.new(
|
248
|
+
min: min_range.min,
|
249
|
+
include_min: min_range.include_min,
|
250
|
+
max: max_range.max,
|
251
|
+
include_max: max_range.include_max
|
252
|
+
)
|
253
|
+
end
|
254
|
+
|
255
|
+
# The span covered by two ranges
|
256
|
+
#
|
257
|
+
# If self and other are contiguous, this builds a union of the two ranges.
|
258
|
+
# (if they aren't you are probably calling the wrong method)
|
259
|
+
def span(other)
|
260
|
+
return self if other.empty?
|
261
|
+
|
262
|
+
min_range =
|
263
|
+
if !min
|
264
|
+
self
|
265
|
+
elsif !other.min
|
266
|
+
other
|
267
|
+
else
|
268
|
+
case min <=> other.min
|
269
|
+
when 0
|
270
|
+
include_min ? self : other
|
271
|
+
when -1
|
272
|
+
self
|
273
|
+
when 1
|
274
|
+
other
|
275
|
+
end
|
276
|
+
end
|
277
|
+
|
278
|
+
max_range =
|
279
|
+
if !max
|
280
|
+
self
|
281
|
+
elsif !other.max
|
282
|
+
other
|
283
|
+
else
|
284
|
+
case max <=> other.max
|
285
|
+
when 0
|
286
|
+
include_max ? self : other
|
287
|
+
when -1
|
288
|
+
other
|
289
|
+
when 1
|
290
|
+
self
|
291
|
+
end
|
292
|
+
end
|
293
|
+
|
294
|
+
VersionRange.new(
|
295
|
+
min: min_range.min,
|
296
|
+
include_min: min_range.include_min,
|
297
|
+
max: max_range.max,
|
298
|
+
include_max: max_range.include_max
|
299
|
+
)
|
300
|
+
end
|
301
|
+
|
302
|
+
def union(other)
|
303
|
+
return other.union(self) if other.is_a?(VersionUnion)
|
304
|
+
|
305
|
+
if contiguous_to?(other)
|
306
|
+
span(other)
|
307
|
+
else
|
308
|
+
VersionUnion.union([self, other])
|
309
|
+
end
|
310
|
+
end
|
311
|
+
|
312
|
+
def contiguous_to?(other)
|
313
|
+
return false if other.empty?
|
314
|
+
|
315
|
+
intersects?(other) ||
|
316
|
+
(min == other.max && (include_min || other.include_max)) ||
|
317
|
+
(max == other.min && (include_max || other.include_min))
|
318
|
+
end
|
319
|
+
|
320
|
+
def allows_all?(other)
|
321
|
+
return true if other.empty?
|
322
|
+
|
323
|
+
if other.is_a?(VersionUnion)
|
324
|
+
return VersionUnion.new([self]).allows_all?(other)
|
325
|
+
end
|
326
|
+
|
327
|
+
return false if max && !other.max
|
328
|
+
return false if min && !other.min
|
329
|
+
|
330
|
+
if min
|
331
|
+
case min <=> other.min
|
332
|
+
when -1
|
333
|
+
when 0
|
334
|
+
return false if !include_min && other.include_min
|
335
|
+
when 1
|
336
|
+
return false
|
337
|
+
end
|
338
|
+
end
|
339
|
+
|
340
|
+
if max
|
341
|
+
case max <=> other.max
|
342
|
+
when -1
|
343
|
+
return false
|
344
|
+
when 0
|
345
|
+
return false if !include_max && other.include_max
|
346
|
+
when 1
|
347
|
+
end
|
348
|
+
end
|
349
|
+
|
350
|
+
true
|
351
|
+
end
|
352
|
+
|
353
|
+
def any?
|
354
|
+
!min && !max
|
355
|
+
end
|
356
|
+
|
357
|
+
def empty?
|
358
|
+
false
|
359
|
+
end
|
360
|
+
|
361
|
+
def to_s
|
362
|
+
@name ||= constraints.join(", ")
|
363
|
+
end
|
364
|
+
|
365
|
+
def inspect
|
366
|
+
"#<#{self.class} #{to_s}>"
|
367
|
+
end
|
368
|
+
|
369
|
+
def upper_invert
|
370
|
+
return self.class.empty unless max
|
371
|
+
|
372
|
+
VersionRange.new(min: max, include_min: !include_max)
|
373
|
+
end
|
374
|
+
|
375
|
+
def invert
|
376
|
+
return self.class.empty if any?
|
377
|
+
|
378
|
+
low = VersionRange.new(max: min, include_max: !include_min)
|
379
|
+
high = VersionRange.new(min: max, include_min: !include_max)
|
380
|
+
|
381
|
+
if !min
|
382
|
+
high
|
383
|
+
elsif !max
|
384
|
+
low
|
385
|
+
else
|
386
|
+
low.union(high)
|
387
|
+
end
|
388
|
+
end
|
389
|
+
|
390
|
+
def ==(other)
|
391
|
+
self.class == other.class &&
|
392
|
+
min == other.min &&
|
393
|
+
max == other.max &&
|
394
|
+
include_min == other.include_min &&
|
395
|
+
include_max == other.include_max
|
396
|
+
end
|
397
|
+
|
398
|
+
private
|
399
|
+
|
400
|
+
def constraints
|
401
|
+
return ["any"] if any?
|
402
|
+
return ["= #{min}"] if min.to_s == max.to_s
|
403
|
+
|
404
|
+
c = []
|
405
|
+
c << "#{include_min ? ">=" : ">"} #{min}" if min
|
406
|
+
c << "#{include_max ? "<=" : "<"} #{max}" if max
|
407
|
+
c
|
408
|
+
end
|
409
|
+
|
410
|
+
end
|
411
|
+
end
|
@@ -0,0 +1,248 @@
|
|
1
|
+
require_relative 'partial_solution'
|
2
|
+
require_relative 'term'
|
3
|
+
require_relative 'incompatibility'
|
4
|
+
require_relative 'solve_failure'
|
5
|
+
|
6
|
+
module Bundler::PubGrub
|
7
|
+
class VersionSolver
|
8
|
+
attr_reader :logger
|
9
|
+
attr_reader :source
|
10
|
+
attr_reader :solution
|
11
|
+
|
12
|
+
def initialize(source:, root: Package.root, logger: Bundler::PubGrub.logger)
|
13
|
+
@logger = logger
|
14
|
+
|
15
|
+
@source = source
|
16
|
+
|
17
|
+
# { package => [incompatibility, ...]}
|
18
|
+
@incompatibilities = Hash.new do |h, k|
|
19
|
+
h[k] = []
|
20
|
+
end
|
21
|
+
|
22
|
+
@seen_incompatibilities = {}
|
23
|
+
|
24
|
+
@solution = PartialSolution.new
|
25
|
+
|
26
|
+
add_incompatibility Incompatibility.new([
|
27
|
+
Term.new(VersionConstraint.any(root), false)
|
28
|
+
], cause: :root)
|
29
|
+
|
30
|
+
propagate(root)
|
31
|
+
end
|
32
|
+
|
33
|
+
def solved?
|
34
|
+
solution.unsatisfied.empty?
|
35
|
+
end
|
36
|
+
|
37
|
+
# Returns true if there is more work to be done, false otherwise
|
38
|
+
def work
|
39
|
+
return false if solved?
|
40
|
+
|
41
|
+
next_package = choose_package_version
|
42
|
+
propagate(next_package)
|
43
|
+
|
44
|
+
if solved?
|
45
|
+
logger.info { "Solution found after #{solution.attempted_solutions} attempts:" }
|
46
|
+
solution.decisions.each do |package, version|
|
47
|
+
next if Package.root?(package)
|
48
|
+
logger.info { "* #{package} #{version}" }
|
49
|
+
end
|
50
|
+
|
51
|
+
false
|
52
|
+
else
|
53
|
+
true
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def solve
|
58
|
+
work until solved?
|
59
|
+
|
60
|
+
solution.decisions
|
61
|
+
end
|
62
|
+
|
63
|
+
alias_method :result, :solve
|
64
|
+
|
65
|
+
private
|
66
|
+
|
67
|
+
def propagate(initial_package)
|
68
|
+
changed = [initial_package]
|
69
|
+
while package = changed.shift
|
70
|
+
@incompatibilities[package].reverse_each do |incompatibility|
|
71
|
+
result = propagate_incompatibility(incompatibility)
|
72
|
+
if result == :conflict
|
73
|
+
root_cause = resolve_conflict(incompatibility)
|
74
|
+
changed.clear
|
75
|
+
changed << propagate_incompatibility(root_cause)
|
76
|
+
elsif result # should be a Package
|
77
|
+
changed << result
|
78
|
+
end
|
79
|
+
end
|
80
|
+
changed.uniq!
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def propagate_incompatibility(incompatibility)
|
85
|
+
unsatisfied = nil
|
86
|
+
incompatibility.terms.each do |term|
|
87
|
+
relation = solution.relation(term)
|
88
|
+
if relation == :disjoint
|
89
|
+
return nil
|
90
|
+
elsif relation == :overlap
|
91
|
+
# If more than one term is inconclusive, we can't deduce anything
|
92
|
+
return nil if unsatisfied
|
93
|
+
unsatisfied = term
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
if !unsatisfied
|
98
|
+
return :conflict
|
99
|
+
end
|
100
|
+
|
101
|
+
logger.debug { "derived: #{unsatisfied.invert}" }
|
102
|
+
|
103
|
+
solution.derive(unsatisfied.invert, incompatibility)
|
104
|
+
|
105
|
+
unsatisfied.package
|
106
|
+
end
|
107
|
+
|
108
|
+
def next_package_to_try
|
109
|
+
solution.unsatisfied.min_by do |term|
|
110
|
+
package = term.package
|
111
|
+
range = term.constraint.range
|
112
|
+
matching_versions = source.versions_for(package, range)
|
113
|
+
higher_versions = source.versions_for(package, range.upper_invert)
|
114
|
+
|
115
|
+
[matching_versions.count <= 1 ? 0 : 1, higher_versions.count]
|
116
|
+
end.package
|
117
|
+
end
|
118
|
+
|
119
|
+
def choose_package_version
|
120
|
+
if solution.unsatisfied.empty?
|
121
|
+
logger.info "No packages unsatisfied. Solving complete!"
|
122
|
+
return nil
|
123
|
+
end
|
124
|
+
|
125
|
+
package = next_package_to_try
|
126
|
+
unsatisfied_term = solution.unsatisfied.find { |t| t.package == package }
|
127
|
+
version = source.versions_for(package, unsatisfied_term.constraint.range).first
|
128
|
+
logger.debug { "attempting #{package} #{version}" }
|
129
|
+
|
130
|
+
if version.nil?
|
131
|
+
add_incompatibility source.no_versions_incompatibility_for(package, unsatisfied_term)
|
132
|
+
return package
|
133
|
+
end
|
134
|
+
|
135
|
+
conflict = false
|
136
|
+
|
137
|
+
source.incompatibilities_for(package, version).each do |incompatibility|
|
138
|
+
if @seen_incompatibilities.include?(incompatibility)
|
139
|
+
logger.debug { "knew: #{incompatibility}" }
|
140
|
+
next
|
141
|
+
end
|
142
|
+
@seen_incompatibilities[incompatibility] = true
|
143
|
+
|
144
|
+
add_incompatibility incompatibility
|
145
|
+
|
146
|
+
conflict ||= incompatibility.terms.all? do |term|
|
147
|
+
term.package == package || solution.satisfies?(term)
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
unless conflict
|
152
|
+
logger.info { "selected #{package} #{version}" }
|
153
|
+
|
154
|
+
solution.decide(package, version)
|
155
|
+
else
|
156
|
+
logger.info { "conflict: #{conflict.inspect}" }
|
157
|
+
end
|
158
|
+
|
159
|
+
package
|
160
|
+
end
|
161
|
+
|
162
|
+
def resolve_conflict(incompatibility)
|
163
|
+
logger.info { "conflict: #{incompatibility}" }
|
164
|
+
|
165
|
+
new_incompatibility = nil
|
166
|
+
|
167
|
+
while !incompatibility.failure?
|
168
|
+
most_recent_term = nil
|
169
|
+
most_recent_satisfier = nil
|
170
|
+
difference = nil
|
171
|
+
|
172
|
+
previous_level = 1
|
173
|
+
|
174
|
+
incompatibility.terms.each do |term|
|
175
|
+
satisfier = solution.satisfier(term)
|
176
|
+
|
177
|
+
if most_recent_satisfier.nil?
|
178
|
+
most_recent_term = term
|
179
|
+
most_recent_satisfier = satisfier
|
180
|
+
elsif most_recent_satisfier.index < satisfier.index
|
181
|
+
previous_level = [previous_level, most_recent_satisfier.decision_level].max
|
182
|
+
most_recent_term = term
|
183
|
+
most_recent_satisfier = satisfier
|
184
|
+
difference = nil
|
185
|
+
else
|
186
|
+
previous_level = [previous_level, satisfier.decision_level].max
|
187
|
+
end
|
188
|
+
|
189
|
+
if most_recent_term == term
|
190
|
+
difference = most_recent_satisfier.term.difference(most_recent_term)
|
191
|
+
if difference.empty?
|
192
|
+
difference = nil
|
193
|
+
else
|
194
|
+
difference_satisfier = solution.satisfier(difference.inverse)
|
195
|
+
previous_level = [previous_level, difference_satisfier.decision_level].max
|
196
|
+
end
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
if previous_level < most_recent_satisfier.decision_level ||
|
201
|
+
most_recent_satisfier.decision?
|
202
|
+
|
203
|
+
logger.info { "backtracking to #{previous_level}" }
|
204
|
+
solution.backtrack(previous_level)
|
205
|
+
|
206
|
+
if new_incompatibility
|
207
|
+
add_incompatibility(new_incompatibility)
|
208
|
+
end
|
209
|
+
|
210
|
+
return incompatibility
|
211
|
+
end
|
212
|
+
|
213
|
+
new_terms = []
|
214
|
+
new_terms += incompatibility.terms - [most_recent_term]
|
215
|
+
new_terms += most_recent_satisfier.cause.terms.reject { |term|
|
216
|
+
term.package == most_recent_satisfier.term.package
|
217
|
+
}
|
218
|
+
if difference
|
219
|
+
new_terms << difference.invert
|
220
|
+
end
|
221
|
+
|
222
|
+
new_incompatibility = Incompatibility.new(new_terms, cause: Incompatibility::ConflictCause.new(incompatibility, most_recent_satisfier.cause))
|
223
|
+
|
224
|
+
if incompatibility.to_s == new_incompatibility.to_s
|
225
|
+
logger.info { "!! failed to resolve conflicts, this shouldn't have happened" }
|
226
|
+
break
|
227
|
+
end
|
228
|
+
|
229
|
+
incompatibility = new_incompatibility
|
230
|
+
|
231
|
+
partially = difference ? " partially" : ""
|
232
|
+
logger.info { "! #{most_recent_term} is#{partially} satisfied by #{most_recent_satisfier.term}" }
|
233
|
+
logger.info { "! which is caused by #{most_recent_satisfier.cause}" }
|
234
|
+
logger.info { "! thus #{incompatibility}" }
|
235
|
+
end
|
236
|
+
|
237
|
+
raise SolveFailure.new(incompatibility)
|
238
|
+
end
|
239
|
+
|
240
|
+
def add_incompatibility(incompatibility)
|
241
|
+
logger.debug { "fact: #{incompatibility}" }
|
242
|
+
incompatibility.terms.each do |term|
|
243
|
+
package = term.package
|
244
|
+
@incompatibilities[package] << incompatibility
|
245
|
+
end
|
246
|
+
end
|
247
|
+
end
|
248
|
+
end
|