summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/bundler/cli.rb12
-rw-r--r--lib/bundler/cli/cache.rb2
-rw-r--r--lib/bundler/cli/package.rb6
-rw-r--r--lib/bundler/feature_flag.rb1
-rw-r--r--lib/bundler/source/git.rb2
-rw-r--r--lib/bundler/source/path.rb2
-rw-r--r--spec/cache/git_spec.rb16
-rw-r--r--spec/commands/package_spec.rb8
-rw-r--r--spec/install/deploy_spec.rb2
-rw-r--r--spec/install/gemfile/git_spec.rb2
-rw-r--r--spec/lock/lockfile_bundler_1_spec.rb4
-rw-r--r--spec/lock/lockfile_spec.rb4
-rw-r--r--spec/plugins/source/example_spec.rb4
13 files changed, 36 insertions, 29 deletions
diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb
index 954e19b530..69bb5f0ac3 100644
--- a/lib/bundler/cli.rb
+++ b/lib/bundler/cli.rb
@@ -348,8 +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, :default => Bundler.feature_flag.cache_command_is_package? || nil,
- :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
@@ -359,8 +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, :default => Bundler.feature_flag.cache_command_is_package? || nil,
- :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 42210f0f3d..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,7 +161,7 @@ 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
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