diff options
author | The Bundler Bot <bot@bundler.io> | 2017-08-28 16:33:48 +0000 |
---|---|---|
committer | The Bundler Bot <bot@bundler.io> | 2017-08-28 16:33:48 +0000 |
commit | 766f412f338edb1502c62fb4cc2a6ae6678f55d4 (patch) | |
tree | f02940a8e16b6a868cb6bdc4b782bb5801c144cb | |
parent | b0a1cabc5eaa4b5386c9a86e39abcbeaf72aaf3f (diff) | |
parent | 6101d6276bceb8bf0f687a3fdb5cbae3847e8598 (diff) | |
download | bundler-766f412f338edb1502c62fb4cc2a6ae6678f55d4.tar.gz |
Auto merge of #5955 - bundler:seg-bundler-2-defaults, r=indirect
Default to packaging all on 2.0
This is going to be the last set of changes to defaults in Bundler 2.
@colby-swandale @indirect are there other changes I should be making here?
-rw-r--r-- | lib/bundler/cli.rb | 10 | ||||
-rw-r--r-- | lib/bundler/cli/cache.rb | 2 | ||||
-rw-r--r-- | lib/bundler/cli/package.rb | 6 | ||||
-rw-r--r-- | lib/bundler/feature_flag.rb | 1 | ||||
-rw-r--r-- | lib/bundler/source/git.rb | 2 | ||||
-rw-r--r-- | lib/bundler/source/path.rb | 2 | ||||
-rw-r--r-- | spec/cache/git_spec.rb | 18 | ||||
-rw-r--r-- | spec/cache/path_spec.rb | 2 | ||||
-rw-r--r-- | spec/commands/package_spec.rb | 8 | ||||
-rw-r--r-- | spec/install/deploy_spec.rb | 2 | ||||
-rw-r--r-- | spec/install/gemfile/git_spec.rb | 2 | ||||
-rw-r--r-- | spec/lock/lockfile_bundler_1_spec.rb | 4 | ||||
-rw-r--r-- | spec/lock/lockfile_spec.rb | 4 | ||||
-rw-r--r-- | spec/plugins/source/example_spec.rb | 4 |
14 files changed, 38 insertions, 29 deletions
diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb index 12fe7adf01..69bb5f0ac3 100644 --- a/lib/bundler/cli.rb +++ b/lib/bundler/cli.rb @@ -348,7 +348,10 @@ module Bundler map %w[cache] => :package else desc "cache [OPTIONS]", "Cache all the gems to vendor/cache", :hide => true - method_option "all", :type => :boolean, :banner => "Include all sources (including path and git)." + unless Bundler.feature_flag.cache_command_is_package? + 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 "no-prune", :type => :boolean, :banner => "Don't remove stale gems from the cache." def cache @@ -358,7 +361,10 @@ module Bundler end desc "#{Bundler.feature_flag.cache_command_is_package? ? :cache : :package} [OPTIONS]", "Locks and then caches all of the gems into vendor/cache" - method_option "all", :type => :boolean, :banner => "Include all sources (including path and git)." + unless Bundler.feature_flag.cache_command_is_package? + 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)." diff --git a/lib/bundler/cli/cache.rb b/lib/bundler/cli/cache.rb index 77e049e7a2..9d2ba87d34 100644 --- a/lib/bundler/cli/cache.rb +++ b/lib/bundler/cli/cache.rb @@ -26,7 +26,7 @@ module Bundler def setup_cache_all Bundler.settings.set_command_option_if_given :cache_all, options[:all] - if Bundler.definition.has_local_dependencies? && !Bundler.settings[:cache_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 package them as well, please pass the --all flag. This will be the default " \ "on Bundler 2.0." diff --git a/lib/bundler/cli/package.rb b/lib/bundler/cli/package.rb index cda41ea623..2dcd0e1e29 100644 --- a/lib/bundler/cli/package.rb +++ b/lib/bundler/cli/package.rb @@ -35,9 +35,11 @@ module Bundler end def setup_cache_all - Bundler.settings.set_command_option_if_given :cache_all, options[:all] + all = options.fetch(:all, Bundler.feature_flag.cache_command_is_package? || nil) - if Bundler.definition.has_local_dependencies? && !Bundler.settings[:cache_all] + 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 package them as well, please pass the --all flag. This will be the default " \ "on Bundler 2.0." diff --git a/lib/bundler/feature_flag.rb b/lib/bundler/feature_flag.rb index 07d11418be..05f28059d7 100644 --- a/lib/bundler/feature_flag.rb +++ b/lib/bundler/feature_flag.rb @@ -29,6 +29,7 @@ module Bundler settings_flag(:allow_bundler_dependency_conflicts) { bundler_2_mode? } settings_flag(:allow_offline_install) { bundler_2_mode? } + settings_flag(:cache_all) { bundler_2_mode? } settings_flag(:cache_command_is_package) { bundler_2_mode? } settings_flag(:console_command) { !bundler_2_mode? } settings_flag(:deployment_means_frozen) { bundler_2_mode? } diff --git a/lib/bundler/source/git.rb b/lib/bundler/source/git.rb index c66cbb17fb..97bc1724a0 100644 --- a/lib/bundler/source/git.rb +++ b/lib/bundler/source/git.rb @@ -187,7 +187,7 @@ module Bundler def cache(spec, custom_path = nil) app_cache_path = app_cache_path(custom_path) - return unless Bundler.settings[:cache_all] + return unless Bundler.feature_flag.cache_all? return if path == app_cache_path cached! FileUtils.rm_rf(app_cache_path) diff --git a/lib/bundler/source/path.rb b/lib/bundler/source/path.rb index afd8723168..ed734bf549 100644 --- a/lib/bundler/source/path.rb +++ b/lib/bundler/source/path.rb @@ -84,7 +84,7 @@ module Bundler def cache(spec, custom_path = nil) app_cache_path = app_cache_path(custom_path) - return unless Bundler.settings[:cache_all] + return unless Bundler.feature_flag.cache_all? return if expand(@original_path).to_s.index(root_path.to_s + "/") == 0 unless @original_path.exist? diff --git a/spec/cache/git_spec.rb b/spec/cache/git_spec.rb index 562fc881c0..33387dbbb2 100644 --- a/spec/cache/git_spec.rb +++ b/spec/cache/git_spec.rb @@ -22,7 +22,7 @@ end gem "foo", :git => '#{lib_path("foo-1.0")}' G - bundle "#{cmd} --all" + bundle "#{cmd}", forgotten_command_line_options([:all, :cache_all] => true) 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 +40,7 @@ end G bundle "install --path vendor/bundle" - bundle "#{cmd} --all" + bundle "#{cmd}", forgotten_command_line_options([:all, :cache_all] => true) 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 +56,8 @@ end gem "foo", :git => '#{lib_path("foo-1.0")}' G - bundle! "#{cmd} --all" - bundle! "#{cmd} --all" + bundle! "#{cmd}", forgotten_command_line_options([:all, :cache_all] => true) + bundle! "#{cmd}", forgotten_command_line_options([:all, :cache_all] => true) expect(last_command.stdout).to include "Updating files in vendor/cache" FileUtils.rm_rf lib_path("foo-1.0") @@ -72,7 +72,7 @@ end gem "foo", :git => '#{lib_path("foo-1.0")}' G - bundle "#{cmd} --all" + bundle "#{cmd}", forgotten_command_line_options([:all, :cache_all] => true) update_git "foo" do |s| s.write "lib/foo.rb", "puts :CACHE" @@ -82,7 +82,7 @@ end expect(ref).not_to eq(old_ref) bundle! "update", :all => bundle_update_requires_all? - bundle! "#{cmd} --all" + bundle! "#{cmd}", forgotten_command_line_options([:all, :cache_all] => true) expect(bundled_app("vendor/cache/foo-1.0-#{ref}")).to exist expect(bundled_app("vendor/cache/foo-1.0-#{old_ref}")).not_to exist @@ -129,7 +129,7 @@ end bundle %(config local.foo #{lib_path("foo-1.0")}) bundle "install" - bundle "#{cmd} --all" + bundle "#{cmd}", forgotten_command_line_options([:all, :cache_all] => true) expect(bundled_app("vendor/cache/foo-invalid-#{ref}")).to exist @@ -161,14 +161,14 @@ end G ref = git.ref_for("master", 11) - bundle "#{cmd} --all" + bundle "#{cmd}", forgotten_command_line_options([:all, :cache_all] => true) 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 expect(the_bundle).to include_gems "has_submodule 1.0" end - it "displays warning message when detecting git repo in Gemfile" do + it "displays warning message when detecting git repo in Gemfile", :bundler => "< 2" do build_git "foo" install_gemfile <<-G diff --git a/spec/cache/path_spec.rb b/spec/cache/path_spec.rb index 327d0abf60..8c6a843476 100644 --- a/spec/cache/path_spec.rb +++ b/spec/cache/path_spec.rb @@ -86,7 +86,7 @@ expect(bundled_app("vendor/cache/bar-1.0")).not_to exist end - it "raises a warning without --all" do + it "raises a warning without --all", :bundler => "< 2" do build_lib "foo" install_gemfile <<-G diff --git a/spec/commands/package_spec.rb b/spec/commands/package_spec.rb index 50d93be127..6351909bc7 100644 --- a/spec/commands/package_spec.rb +++ b/spec/commands/package_spec.rb @@ -24,7 +24,7 @@ RSpec.describe "bundle package" do gem 'bundler' D - bundle "package --all" + bundle :package, forgotten_command_line_options([:all, :cache_all] => true) 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 +54,7 @@ RSpec.describe "bundle package" do gemspec D - bundle! "package --all" + bundle! :package, forgotten_command_line_options([:all, :cache_all] => true) 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 +85,7 @@ RSpec.describe "bundle package" do gemspec D - bundle! "package --all" + bundle! :package, forgotten_command_line_options([:all, :cache_all] => true) 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 +129,7 @@ RSpec.describe "bundle package" do gemspec :name => 'mygem_test' D - bundle! "package --all" + bundle! :package, forgotten_command_line_options([:all, :cache_all] => true) 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 de812b5e65..491801e27a 100644 --- a/spec/install/deploy_spec.rb +++ b/spec/install/deploy_spec.rb @@ -405,7 +405,7 @@ You have deleted from the Gemfile: bundle! :install expect(the_bundle).to include_gems "foo 1.0" - bundle! "package --all" + bundle! :package, forgotten_command_line_options([:all, :cache_all] => true) 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 feafb568dd..7f7a1ae4c9 100644 --- a/spec/install/gemfile/git_spec.rb +++ b/spec/install/gemfile/git_spec.rb @@ -1282,7 +1282,7 @@ In Gemfile: gem 'foo' end G - bundle "package --all" + bundle :package, forgotten_command_line_options([:all, :cache_all] => true) simulate_new_machine bundle! "install", :env => { "PATH" => "" } diff --git a/spec/lock/lockfile_bundler_1_spec.rb b/spec/lock/lockfile_bundler_1_spec.rb index 1aab5e7750..3be45e29dc 100644 --- a/spec/lock/lockfile_bundler_1_spec.rb +++ b/spec/lock/lockfile_bundler_1_spec.rb @@ -612,8 +612,8 @@ RSpec.describe "the lockfile format", :bundler => "< 2" do gem "foo", :path => "#{lib_path("foo-1.0")}" G - bundle! "package --all" - bundle! "install --local" + bundle! :package, forgotten_command_line_options([:all, :cache_all] => true) + bundle! :install, :local => true lockfile_should_be <<-G PATH diff --git a/spec/lock/lockfile_spec.rb b/spec/lock/lockfile_spec.rb index bcf31d9f2c..b4bf81ded2 100644 --- a/spec/lock/lockfile_spec.rb +++ b/spec/lock/lockfile_spec.rb @@ -647,8 +647,8 @@ RSpec.describe "the lockfile format", :bundler => "2" do gem "foo", :path => "#{lib_path("foo-1.0")}" G - bundle! "package --all" - bundle! "install --local" + bundle! :package, forgotten_command_line_options([:all, :cache_all] => true) + bundle! :install, :local => true lockfile_should_be <<-G GEM diff --git a/spec/plugins/source/example_spec.rb b/spec/plugins/source/example_spec.rb index aa3163ad40..4f5e5f3fdb 100644 --- a/spec/plugins/source/example_spec.rb +++ b/spec/plugins/source/example_spec.rb @@ -141,7 +141,7 @@ RSpec.describe "real source plugins" do 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 --all" + bundle :cache, forgotten_command_line_options([:all, :cache_all] => true) 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 @@ -484,7 +484,7 @@ RSpec.describe "real source plugins" do end G - bundle "cache --all" + bundle :cache, forgotten_command_line_options([:all, :cache_all] => true) 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 |