From 73fb69402a6bd1288857809cc59dce6f7047cfeb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Tue, 8 Sep 2020 20:14:44 +0200 Subject: [PATCH] Merge pull request #3932 from rubygems/deprecate_package_all_flag Deprecate `bundle cache --all` flag (cherry picked from commit 5f97b90a4f1c217e9bc852d3282abb74b4312287) --- bundler/lib/bundler/cli.rb | 8 +++++- bundler/lib/bundler/cli/cache.rb | 6 ----- bundler/lib/bundler/definition.rb | 4 --- bundler/spec/cache/git_spec.rb | 26 -------------------- bundler/spec/cache/path_spec.rb | 16 ++++++++++-- bundler/spec/other/major_deprecation_spec.rb | 22 +++++++++++++++++ 6 files changed, 43 insertions(+), 39 deletions(-) diff --git a/bundler/lib/bundler/cli.rb b/bundler/lib/bundler/cli.rb index 203f0539cb5d..8d30001bd480 100644 --- a/bundler/lib/bundler/cli.rb +++ b/bundler/lib/bundler/cli.rb @@ -461,6 +461,12 @@ def outdated(*gems) bundle without having to download any additional gems. D def cache + SharedHelpers.major_deprecation 2, + "The `--all` flag is deprecated because it relies on being " \ + "remembered across bundler invocations, which bundler will no longer " \ + "do in future versions. Instead please use `bundle config set cache_all true`, " \ + "and stop using this flag" if ARGV.include?("--all") + require_relative "cli/cache" Cache.new(options).run end @@ -838,7 +844,7 @@ def flag_deprecation(name, flag_name, option) value = options[name] value = value.join(" ").to_s if option.type == :array - Bundler::SharedHelpers.major_deprecation 2,\ + Bundler::SharedHelpers.major_deprecation 2, "The `#{flag_name}` flag is deprecated because it relies on being " \ "remembered across bundler invocations, which bundler will no longer " \ "do in future versions. Instead please use `bundle config set --local #{name.tr("-", "_")} " \ diff --git a/bundler/lib/bundler/cli/cache.rb b/bundler/lib/bundler/cli/cache.rb index 6b8029e0c077..c14c8877f042 100644 --- a/bundler/lib/bundler/cli/cache.rb +++ b/bundler/lib/bundler/cli/cache.rb @@ -37,12 +37,6 @@ def setup_cache_all all = options.fetch(:all, Bundler.feature_flag.cache_all? || nil) Bundler.settings.set_command_option_if_given :cache_all, all - - if Bundler.definition.has_local_dependencies? && !Bundler.feature_flag.cache_all? - Bundler.ui.warn "Your Gemfile contains path and git dependencies. If you want " \ - "to cache them as well, please pass the --all flag. This will be the default " \ - "on Bundler 3.0." - end end end end diff --git a/bundler/lib/bundler/definition.rb b/bundler/lib/bundler/definition.rb index 749825dd968b..bed0afc9e675 100644 --- a/bundler/lib/bundler/definition.rb +++ b/bundler/lib/bundler/definition.rb @@ -314,10 +314,6 @@ def has_rubygems_remotes? sources.rubygems_sources.any? {|s| s.remotes.any? } end - def has_local_dependencies? - !sources.path_sources.empty? || !sources.git_sources.empty? - end - def spec_git_paths sources.git_sources.map {|s| File.realpath(s.path) if File.exist?(s.path) }.compact end diff --git a/bundler/spec/cache/git_spec.rb b/bundler/spec/cache/git_spec.rb index d481e006660e..97d73907db32 100644 --- a/bundler/spec/cache/git_spec.rb +++ b/bundler/spec/cache/git_spec.rb @@ -174,32 +174,6 @@ expect(the_bundle).to include_gems "has_submodule 1.0" end - it "displays warning message when detecting git repo in Gemfile", :bundler => "< 3" do - build_git "foo" - - install_gemfile <<-G - gem "foo", :git => '#{lib_path("foo-1.0")}' - G - - bundle :cache - - expect(err).to include("Your Gemfile contains path and git dependencies.") - end - - it "does not display warning message if cache_all is set in bundle config" do - build_git "foo" - - install_gemfile <<-G - gem "foo", :git => '#{lib_path("foo-1.0")}' - G - - bundle "config set cache_all true" - bundle :cache - bundle :cache - - expect(err).not_to include("Your Gemfile contains path and git dependencies.") - end - it "caches pre-evaluated gemspecs" do git = build_git "foo" diff --git a/bundler/spec/cache/path_spec.rb b/bundler/spec/cache/path_spec.rb index 0c84d242b572..c81dda7405e1 100644 --- a/bundler/spec/cache/path_spec.rb +++ b/bundler/spec/cache/path_spec.rb @@ -91,7 +91,7 @@ expect(bundled_app("vendor/cache/foo-1.0")).not_to exist end - it "raises a warning without --all", :bundler => "< 3" do + it "does not cache path gems by default", :bundler => "< 3" do build_lib "foo" install_gemfile <<-G @@ -99,10 +99,22 @@ G bundle :cache - expect(err).to match(/please pass the \-\-all flag/) + expect(err).to be_empty expect(bundled_app("vendor/cache/foo-1.0")).not_to exist end + it "caches path gems by default", :bundler => "3" do + build_lib "foo" + + install_gemfile <<-G + gem "foo", :path => '#{lib_path("foo-1.0")}' + G + + bundle :cache + expect(err).to be_empty + expect(bundled_app("vendor/cache/foo-1.0")).to exist + end + it "stores the given flag" do build_lib "foo" diff --git a/bundler/spec/other/major_deprecation_spec.rb b/bundler/spec/other/major_deprecation_spec.rb index e8884a40b25c..d061ca7064bb 100644 --- a/bundler/spec/other/major_deprecation_spec.rb +++ b/bundler/spec/other/major_deprecation_spec.rb @@ -143,6 +143,28 @@ pending "should fail with a helpful error", :bundler => "3" end + context "bundle cache --all" do + before do + install_gemfile <<-G + source "#{file_uri_for(gem_repo1)}" + gem "rack" + G + + bundle "cache --all", :raise_on_error => false + end + + it "should print a deprecation warning", :bundler => "2" do + expect(deprecations).to include( + "The `--all` flag is deprecated because it relies on being " \ + "remembered across bundler invocations, which bundler will no " \ + "longer do in future versions. Instead please use `bundle config set " \ + "cache_all true`, and stop using this flag" + ) + end + + pending "should fail with a helpful error", :bundler => "3" + end + describe "bundle config" do describe "old list interface" do before do