From 04a04719f00c99c846973906111dae4e34310bff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Tue, 23 Jul 2019 16:23:26 +0200 Subject: [PATCH 1/5] Restore `cache_all` flag removal --- lib/bundler/cli.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb index c7af38bcaf9..2f35b83c362 100644 --- a/lib/bundler/cli.rb +++ b/lib/bundler/cli.rb @@ -411,9 +411,10 @@ def outdated(*gems) end desc "#{Bundler.feature_flag.bundler_3_mode? ? :cache : :package} [OPTIONS]", "Locks and then caches all of the gems into vendor/cache" - method_option "all", :type => :boolean, - :default => Bundler.feature_flag.cache_all?, - :banner => "Include all sources (including path and git)." + unless Bundler.feature_flag.cache_all? + method_option "all", :type => :boolean, + :banner => "Include all sources (including path and git)." + end method_option "all-platforms", :type => :boolean, :banner => "Include gems for all platforms present in the lockfile, not only the current one" method_option "cache-path", :type => :string, :banner => "Specify a different cache path than the default (vendor/cache)." From 8c83921d0842acd1e287541eaeaca96b97639f96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Tue, 23 Jul 2019 16:23:45 +0200 Subject: [PATCH 2/5] Prefer feature flag to harcoded check --- lib/bundler/cli/package.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/bundler/cli/package.rb b/lib/bundler/cli/package.rb index 731677b4ec1..b31b67776d4 100644 --- a/lib/bundler/cli/package.rb +++ b/lib/bundler/cli/package.rb @@ -34,7 +34,7 @@ def install end def setup_cache_all - all = options.fetch(:all, Bundler.feature_flag.bundler_3_mode? || nil) + all = options.fetch(:all, Bundler.feature_flag.cache_all? || nil) Bundler.settings.set_command_option_if_given :cache_all, all From 664549427a8421147cdd272fe5ab2c39923fab28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Tue, 23 Jul 2019 17:32:33 +0200 Subject: [PATCH 3/5] Always set `cache_all` via config during tests So that the behavior is the same regardless of the tested bundler version. --- spec/cache/git_spec.rb | 32 +++++++++++++++++++---------- spec/cache/path_spec.rb | 25 ++++++++++++++-------- spec/commands/package_spec.rb | 12 +++++++---- spec/install/deploy_spec.rb | 4 +++- spec/install/gemfile/git_spec.rb | 3 ++- spec/lock/lockfile_spec.rb | 3 ++- spec/plugins/source/example_spec.rb | 12 +++++++---- 7 files changed, 60 insertions(+), 31 deletions(-) diff --git a/spec/cache/git_spec.rb b/spec/cache/git_spec.rb index 1348d033e29..85d1d290436 100644 --- a/spec/cache/git_spec.rb +++ b/spec/cache/git_spec.rb @@ -22,7 +22,8 @@ gem "foo", :git => '#{lib_path("foo-1.0")}' G - bundle cmd, forgotten_command_line_options([:all, :cache_all] => true) + bundle "config set cache_all true" + bundle cmd expect(bundled_app("vendor/cache/foo-1.0-#{ref}")).to exist expect(bundled_app("vendor/cache/foo-1.0-#{ref}/.git")).not_to exist expect(bundled_app("vendor/cache/foo-1.0-#{ref}/.bundlecache")).to be_file @@ -40,7 +41,8 @@ G bundle "install --path vendor/bundle" - bundle cmd, forgotten_command_line_options([:all, :cache_all] => true) + bundle "config set cache_all true" + bundle cmd expect(bundled_app("vendor/cache/foo-1.0-#{ref}")).to exist expect(bundled_app("vendor/cache/foo-1.0-#{ref}/.git")).not_to exist @@ -56,8 +58,9 @@ gem "foo", :git => '#{lib_path("foo-1.0")}' G - bundle! cmd, forgotten_command_line_options([:all, :cache_all] => true) - bundle! cmd, forgotten_command_line_options([:all, :cache_all] => true) + bundle "config set cache_all true" + bundle! cmd + bundle! cmd expect(out).to include "Updating files in vendor/cache" FileUtils.rm_rf lib_path("foo-1.0") @@ -72,7 +75,8 @@ gem "foo", :git => '#{lib_path("foo-1.0")}' G - bundle cmd, forgotten_command_line_options([:all, :cache_all] => true) + bundle "config set cache_all true" + bundle cmd update_git "foo" do |s| s.write "lib/foo.rb", "puts :CACHE" @@ -82,7 +86,8 @@ expect(ref).not_to eq(old_ref) bundle! "update", :all => true - bundle! cmd, forgotten_command_line_options([:all, :cache_all] => true) + bundle "config set cache_all true" + bundle! cmd expect(bundled_app("vendor/cache/foo-1.0-#{ref}")).to exist expect(bundled_app("vendor/cache/foo-1.0-#{old_ref}")).not_to exist @@ -100,7 +105,8 @@ gem "foo", :git => '#{lib_path("foo-1.0")}' G - bundle! cmd, forgotten_command_line_options([:all, :cache_all] => true) + bundle "config set cache_all true" + bundle! cmd update_git "foo" do |s| s.write "lib/foo.rb", "puts :CACHE" @@ -129,7 +135,8 @@ bundle %(config set local.foo #{lib_path("foo-1.0")}) bundle "install" - bundle cmd, forgotten_command_line_options([:all, :cache_all] => true) + bundle "config set cache_all true" + bundle cmd expect(bundled_app("vendor/cache/foo-invalid-#{ref}")).to exist @@ -161,7 +168,8 @@ G ref = git.ref_for("master", 11) - bundle cmd, forgotten_command_line_options([:all, :cache_all] => true) + bundle "config set cache_all true" + bundle cmd expect(bundled_app("vendor/cache/has_submodule-1.0-#{ref}")).to exist expect(bundled_app("vendor/cache/has_submodule-1.0-#{ref}/submodule-1.0")).to exist @@ -187,7 +195,8 @@ gem "foo", :git => '#{lib_path("foo-1.0")}' G - bundle cmd, forgotten_command_line_options([:all, :cache_all] => true) + bundle "config set cache_all true" + bundle cmd bundle cmd expect(err).not_to include("Your Gemfile contains path and git dependencies.") @@ -204,7 +213,8 @@ install_gemfile <<-G gem "foo", :git => '#{lib_path("foo-1.0")}' G - bundle cmd, forgotten_command_line_options([:all, :cache_all] => true) + bundle "config set cache_all true" + bundle cmd ref = git.ref_for("master", 11) gemspec = bundled_app("vendor/cache/foo-1.0-#{ref}/foo.gemspec").read diff --git a/spec/cache/path_spec.rb b/spec/cache/path_spec.rb index 0d7b154a37c..3bbd7b1805c 100644 --- a/spec/cache/path_spec.rb +++ b/spec/cache/path_spec.rb @@ -9,7 +9,8 @@ gem "foo", :path => '#{bundled_app("lib/foo")}' G - bundle cmd, forgotten_command_line_options([:all, :cache_all] => true) + bundle "config set cache_all true" + bundle cmd expect(bundled_app("vendor/cache/foo-1.0")).not_to exist expect(the_bundle).to include_gems "foo 1.0" end @@ -21,7 +22,8 @@ gem "foo", :path => '#{lib_path("foo-1.0")}' G - bundle cmd, forgotten_command_line_options([:all, :cache_all] => true) + bundle "config set cache_all true" + bundle cmd expect(bundled_app("vendor/cache/foo-1.0")).to exist expect(bundled_app("vendor/cache/foo-1.0/.bundlecache")).to be_file @@ -39,7 +41,8 @@ gem "#{libname}", :path => '#{libpath}' G - bundle cmd, forgotten_command_line_options([:all, :cache_all] => true) + bundle "config set cache_all true" + bundle cmd expect(bundled_app("vendor/cache/#{libname}")).to exist expect(bundled_app("vendor/cache/#{libname}/.bundlecache")).to be_file @@ -54,13 +57,14 @@ gem "foo", :path => '#{lib_path("foo-1.0")}' G - bundle cmd, forgotten_command_line_options([:all, :cache_all] => true) + bundle "config set cache_all true" + bundle cmd build_lib "foo" do |s| s.write "lib/foo.rb", "puts :CACHE" end - bundle cmd, forgotten_command_line_options([:all, :cache_all] => true) + bundle cmd expect(bundled_app("vendor/cache/foo-1.0")).to exist FileUtils.rm_rf lib_path("foo-1.0") @@ -76,13 +80,14 @@ gem "foo", :path => '#{lib_path("foo-1.0")}' G - bundle cmd, forgotten_command_line_options([:all, :cache_all] => true) + bundle "config set cache_all true" + bundle cmd install_gemfile <<-G gem "bar", :path => '#{lib_path("bar-1.0")}' G - bundle cmd, forgotten_command_line_options([:all, :cache_all] => true) + bundle cmd expect(bundled_app("vendor/cache/bar-1.0")).not_to exist end @@ -105,7 +110,8 @@ gem "foo", :path => '#{lib_path("foo-1.0")}' G - bundle cmd, forgotten_command_line_options([:all, :cache_all] => true) + bundle "config set cache_all true" + bundle cmd build_lib "bar" install_gemfile <<-G @@ -124,7 +130,8 @@ gem "foo", :path => '#{lib_path("foo-1.0")}' G - bundle cmd, forgotten_command_line_options([:all, :cache_all] => true) + bundle "config set cache_all true" + bundle cmd build_lib "baz" gemfile <<-G diff --git a/spec/commands/package_spec.rb b/spec/commands/package_spec.rb index e051743fd06..da22c002eb7 100644 --- a/spec/commands/package_spec.rb +++ b/spec/commands/package_spec.rb @@ -24,7 +24,8 @@ gem 'bundler' D - bundle :package, forgotten_command_line_options([:all, :cache_all] => true) + bundle "config set cache_all true" + bundle :package expect(bundled_app("vendor/cache/rack-1.0.0.gem")).to exist expect(bundled_app("vendor/cache/bundler-0.9.gem")).to_not exist @@ -54,7 +55,8 @@ gemspec D - bundle! :package, forgotten_command_line_options([:all, :cache_all] => true) + bundle "config set cache_all true" + bundle! :package expect(bundled_app("vendor/cache/rack-1.0.0.gem")).to exist expect(bundled_app("vendor/cache/nokogiri-1.4.2.gem")).to exist @@ -85,7 +87,8 @@ gemspec D - bundle! :package, forgotten_command_line_options([:all, :cache_all] => true) + bundle "config set cache_all true" + bundle! :package expect(bundled_app("vendor/cache/rack-1.0.0.gem")).to exist expect(bundled_app("vendor/cache/nokogiri-1.4.2.gem")).to exist @@ -129,7 +132,8 @@ gemspec :name => 'mygem_test' D - bundle! :package, forgotten_command_line_options([:all, :cache_all] => true) + bundle "config set cache_all true" + bundle! :package expect(bundled_app("vendor/cache/rack-1.0.0.gem")).to exist expect(bundled_app("vendor/cache/nokogiri-1.4.2.gem")).to exist diff --git a/spec/install/deploy_spec.rb b/spec/install/deploy_spec.rb index 3fb6d289431..79a344eaa13 100644 --- a/spec/install/deploy_spec.rb +++ b/spec/install/deploy_spec.rb @@ -388,7 +388,9 @@ bundle! :install expect(the_bundle).to include_gems "foo 1.0" - bundle! :package, forgotten_command_line_options([:all, :cache_all] => true) + + bundle "config set cache_all true" + bundle! :package expect(bundled_app("vendor/cache/foo")).to be_directory bundle! "install --local" diff --git a/spec/install/gemfile/git_spec.rb b/spec/install/gemfile/git_spec.rb index f2dcd33d7df..afcac8b153e 100644 --- a/spec/install/gemfile/git_spec.rb +++ b/spec/install/gemfile/git_spec.rb @@ -1390,7 +1390,8 @@ gem 'foo' end G - bundle :package, forgotten_command_line_options([:all, :cache_all] => true) + bundle "config set cache_all true" + bundle :package simulate_new_machine bundle! "install", :env => { "PATH" => "" } diff --git a/spec/lock/lockfile_spec.rb b/spec/lock/lockfile_spec.rb index e32bb83b3d1..df30bc04008 100644 --- a/spec/lock/lockfile_spec.rb +++ b/spec/lock/lockfile_spec.rb @@ -620,7 +620,8 @@ gem "foo", :path => "#{lib_path("foo-1.0")}" G - bundle! :package, forgotten_command_line_options([:all, :cache_all] => true) + bundle "config set cache_all true" + bundle! :package bundle! :install, :local => true lockfile_should_be <<-G diff --git a/spec/plugins/source/example_spec.rb b/spec/plugins/source/example_spec.rb index 93b61b850ac..7bc8fb0f29b 100644 --- a/spec/plugins/source/example_spec.rb +++ b/spec/plugins/source/example_spec.rb @@ -145,7 +145,8 @@ def install(spec, opts) let(:uri_hash) { Digest(:SHA1).hexdigest(lib_path("a-path-gem-1.0").to_s) } it "copies repository to vendor cache and uses it" do bundle "install" - bundle :cache, forgotten_command_line_options([:all, :cache_all] => true) + bundle "config set cache_all true" + bundle :cache expect(bundled_app("vendor/cache/a-path-gem-1.0-#{uri_hash}")).to exist expect(bundled_app("vendor/cache/a-path-gem-1.0-#{uri_hash}/.git")).not_to exist @@ -157,7 +158,8 @@ def install(spec, opts) it "copies repository to vendor cache and uses it even when installed with bundle --path" do bundle! :install, forgotten_command_line_options(:path => "vendor/bundle") - bundle! :cache, forgotten_command_line_options([:all, :cache_all] => true) + bundle "config set cache_all true" + bundle! :cache expect(bundled_app("vendor/cache/a-path-gem-1.0-#{uri_hash}")).to exist @@ -167,7 +169,8 @@ def install(spec, opts) it "bundler package copies repository to vendor cache" do bundle! :install, forgotten_command_line_options(:path => "vendor/bundle") - bundle! :package, forgotten_command_line_options([:all, :cache_all] => true) + bundle "config set cache_all true" + bundle! :package expect(bundled_app("vendor/cache/a-path-gem-1.0-#{uri_hash}")).to exist @@ -492,7 +495,8 @@ def installed? end G - bundle :cache, forgotten_command_line_options([:all, :cache_all] => true) + bundle "config set cache_all true" + bundle :cache expect(bundled_app("vendor/cache/foo-1.0-#{ref}")).to exist expect(bundled_app("vendor/cache/foo-1.0-#{ref}/.git")).not_to exist expect(bundled_app("vendor/cache/foo-1.0-#{ref}/.bundlecache")).to be_file From 6cb28e3aeb7d01d9b8cecaa5f86eff056be9c8c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Tue, 23 Jul 2019 19:03:19 +0200 Subject: [PATCH 4/5] Remove unnecessary indirections These specs are only run on bundler 2, so the compatibility method is not needed. --- spec/commands/binstubs_spec.rb | 2 +- spec/runtime/executable_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/commands/binstubs_spec.rb b/spec/commands/binstubs_spec.rb index 3e2f7a53dea..f3e82335708 100644 --- a/spec/commands/binstubs_spec.rb +++ b/spec/commands/binstubs_spec.rb @@ -301,7 +301,7 @@ gem "rails" G - bundle! "binstubs rack", forgotten_command_line_options([:path, :bin] => "exec") + bundle! "binstubs rack", :path => "exec" bundle! :install expect(bundled_app("exec/rails")).to exist diff --git a/spec/runtime/executable_spec.rb b/spec/runtime/executable_spec.rb index e293958f82e..003be97cd67 100644 --- a/spec/runtime/executable_spec.rb +++ b/spec/runtime/executable_spec.rb @@ -116,7 +116,7 @@ gem "activesupport" G - bundle! :install, forgotten_command_line_options([:binstubs, :bin] => "bin") + bundle! :install, :binstubs => "bin" gemfile <<-G source "#{file_uri_for(gem_repo1)}" From 5b285685a4c5d516c9f7ed5149abf9505a4e9eaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Tue, 23 Jul 2019 17:33:27 +0200 Subject: [PATCH 5/5] Remove now unused logic --- spec/support/helpers.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/spec/support/helpers.rb b/spec/support/helpers.rb index 922555ff603..2445b566aac 100644 --- a/spec/support/helpers.rb +++ b/spec/support/helpers.rb @@ -158,7 +158,6 @@ def bundle(cmd, options = {}) def forgotten_command_line_options(options) remembered = Bundler::VERSION.split(".", 2).first == "2" options = options.map do |k, v| - k = Array(k)[remembered ? 0 : -1] v = '""' if v && v.to_s.empty? [k, v] end