Skip to content

Commit

Permalink
Merge pull request #3932 from rubygems/deprecate_package_all_flag
Browse files Browse the repository at this point in the history
Deprecate `bundle cache --all` flag
  • Loading branch information
deivid-rodriguez committed Sep 8, 2020
2 parents a452809 + 31f32c7 commit 5f97b90
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 39 deletions.
8 changes: 7 additions & 1 deletion bundler/lib/bundler/cli.rb
Expand Up @@ -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
Expand Down Expand Up @@ -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("-", "_")} " \
Expand Down
6 changes: 0 additions & 6 deletions bundler/lib/bundler/cli/cache.rb
Expand Up @@ -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
4 changes: 0 additions & 4 deletions bundler/lib/bundler/definition.rb
Expand Up @@ -319,10 +319,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
Expand Down
26 changes: 0 additions & 26 deletions bundler/spec/cache/git_spec.rb
Expand Up @@ -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"

Expand Down
16 changes: 14 additions & 2 deletions bundler/spec/cache/path_spec.rb
Expand Up @@ -91,18 +91,30 @@
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
gem "foo", :path => '#{lib_path("foo-1.0")}'
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"

Expand Down
22 changes: 22 additions & 0 deletions bundler/spec/other/major_deprecation_spec.rb
Expand Up @@ -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
Expand Down

0 comments on commit 5f97b90

Please sign in to comment.