Skip to content
This repository was archived by the owner on Apr 14, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/bundler/feature_flag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def self.settings_method(name, key, &default)
settings_flag(:plugins) { @bundler_version >= Gem::Version.new("1.14") }
settings_flag(:prefer_gems_rb) { bundler_2_mode? }
settings_flag(:skip_default_git_sources) { bundler_2_mode? }
settings_flag(:suppress_install_using_messages) { bundler_2_mode? }
settings_flag(:unlock_source_unlocks_spec) { !bundler_2_mode? }
settings_flag(:update_requires_all_flag) { bundler_2_mode? }

Expand Down
1 change: 1 addition & 0 deletions lib/bundler/settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class Settings
prefer_gems_rb
silence_root_warning
skip_default_git_sources
suppress_install_using_messages
unlock_source_unlocks_spec
update_requires_all_flag
].freeze
Expand Down
8 changes: 8 additions & 0 deletions lib/bundler/source.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,13 @@ def version_color(spec_version, locked_spec_version)
def earlier_version?(spec_version, locked_spec_version)
Gem::Version.new(spec_version) < Gem::Version.new(locked_spec_version)
end

def print_using_message(message)
if !message.include?("(was ") && Bundler.feature_flag.suppress_install_using_messages?
Bundler.ui.debug message
else
Bundler.ui.info message
end
end
end
end
2 changes: 1 addition & 1 deletion lib/bundler/source/git.rb
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def specs(*)
def install(spec, options = {})
force = options[:force]

Bundler.ui.info "Using #{version_message(spec)} from #{self}"
print_using_message "Using #{version_message(spec)} from #{self}"

if requires_checkout? && !@copied && !force
Bundler.ui.debug " * Checking out revision: #{ref}"
Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/source/metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def options
end

def install(spec, _opts = {})
Bundler.ui.info "Using #{version_message(spec)}"
print_using_message "Using #{version_message(spec)}"
nil
end

Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/source/path.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def name
end

def install(spec, options = {})
Bundler.ui.info "Using #{version_message(spec)} from #{self}"
print_using_message "Using #{version_message(spec)} from #{self}"
generate_bin(spec, :disable_extensions => true)
nil # no post-install message
end
Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/source/rubygems.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def install(spec, opts = {})
end

if installed?(spec) && !force
Bundler.ui.info "Using #{version_message(spec)}"
print_using_message "Using #{version_message(spec)}"
return nil # no post-install message
end

Expand Down
3 changes: 3 additions & 0 deletions man/bundle-config.ronn
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,9 @@ learn more about their operation in [bundle install(1)][bundle-install].
* `skip_default_git_sources` (`BUNDLE_SKIP_DEFAULT_GIT_SOURCES`):
Whether Bundler should skip adding default git source shortcuts to the
Gemfile DSL.
* `suppress_install_using_messages` (`BUNDLE_SUPPRESS_INSTALL_USING_MESSAGES`):
Avoid printing `Using ...` messages during installation when the version of
a gem has not changed.

In general, you should set these settings per-application by using the applicable
flag to the [bundle install(1)][bundle-install] or [bundle package(1)][bundle-package] command.
Expand Down
9 changes: 3 additions & 6 deletions spec/commands/pristine_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@
foo_changes_txt = Pathname.new(foo.full_gem_path).join("lib/changes.txt")
FileUtils.touch(foo_changes_txt)
expect(foo_changes_txt).to be_file
foo_ref = Spec::Builders::GitReader.new(lib_path("foo")).ref_for("HEAD", 6)

bar = Bundler.definition.specs["bar"].first
bar_changes_txt = Pathname.new(bar.full_gem_path).join("lib/changes.txt")
Expand All @@ -130,11 +129,9 @@

bundle! "pristine foo bar weakling"

expect(out).to eq(strip_whitespace(<<-EOS).strip)
Cannot pristine bar (1.0). Gem is sourced from local path.
Using foo 1.0 from #{lib_path("foo")} (at master@#{foo_ref})
Installing weakling 1.0
EOS
expect(out).to include("Cannot pristine bar (1.0). Gem is sourced from local path.").
and include("Installing weakling 1.0")

expect(weakling_changes_txt).not_to be_file
expect(foo_changes_txt).not_to be_file
expect(bar_changes_txt).to be_file
Expand Down
36 changes: 35 additions & 1 deletion spec/commands/update_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@
end

RSpec.describe "bundle update" do
it "shows the previous version of the gem when updated from rubygems source" do
it "shows the previous version of the gem when updated from rubygems source", :bundler => "< 2" do
build_repo2

install_gemfile <<-G
Expand All @@ -449,6 +449,40 @@
expect(out).to include("Installing activesupport 3.0 (was 2.3.5)")
end

context "with suppress_install_using_messages set" do
before { bundle! "config suppress_install_using_messages true" }

it "only prints `Using` for versions that have changed" do
build_repo4 do
build_gem "bar"
build_gem "foo"
end

install_gemfile! <<-G
source "file://#{gem_repo4}"
gem "bar"
gem "foo"
G

bundle! "update", :all => bundle_update_requires_all?
out.gsub!(/RubyGems [\d\.]+ is not threadsafe.*\n?/, "")
expect(out).to include "Resolving dependencies...\nBundle updated!"

update_repo4 do
build_gem "foo", "2.0"
end

bundle! "update", :all => bundle_update_requires_all?
out.gsub!(/RubyGems [\d\.]+ is not threadsafe.*\n?/, "")
expect(out).to include strip_whitespace(<<-EOS).strip
Resolving dependencies...
Fetching foo 2.0 (was 1.0)
Installing foo 2.0 (was 1.0)
Bundle updated
EOS
end
end

it "shows error message when Gemfile.lock is not preset and gem is specified" do
install_gemfile <<-G
source "file://#{gem_repo2}"
Expand Down
4 changes: 1 addition & 3 deletions spec/install/deploy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -312,15 +312,13 @@
expect(bundled_app("vendor/cache/foo")).to be_directory

bundle! "install --local"
expect(out).to include("Using foo 1.0 from source at")
expect(out).to include("vendor/cache/foo")
expect(out).to include("Updating files in vendor/cache")

simulate_new_machine
bundle! "install --deployment --verbose"
expect(out).not_to include("You are trying to install in deployment mode after changing your Gemfile")
expect(out).not_to include("You have added to the Gemfile")
expect(out).not_to include("You have deleted from the Gemfile")
expect(out).to include("Using foo 1.0 from source at")
expect(out).to include("vendor/cache/foo")
expect(the_bundle).to include_gems "foo 1.0"
end
Expand Down
6 changes: 0 additions & 6 deletions spec/install/force_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
bundle "install --force"

expect(exitstatus).to eq(0) if exitstatus
expect(out).to include "Using bundler"
expect(out).to include "Installing rack 1.0.0"
expect(rack_lib.open(&:read)).to eq("RACK = '1.0.0'\n")
expect(the_bundle).to include_gems "rack 1.0.0"
Expand All @@ -27,7 +26,6 @@
bundle "install --force"

expect(exitstatus).to eq(0) if exitstatus
expect(out).to include "Using bundler"
expect(out).to include "Installing rack 1.0.0"
expect(the_bundle).to include_gems "rack 1.0.0"
end
Expand All @@ -48,17 +46,13 @@
foo_lib.open("w") {|f| f.write("blah blah blah") }
bundle! "install --force"

expect(out).to include "Using bundler"
expect(out).to include "Using foo 1.0 from #{lib_path("foo-1.0")} (at master@#{ref[0, 7]})"
expect(foo_lib.open(&:read)).to eq("FOO = '1.0'\n")
expect(the_bundle).to include_gems "foo 1.0"
end

it "works on first bundle install" do
bundle! "install --force"

expect(out).to include "Using bundler"
expect(out).to include "Using foo 1.0 from #{lib_path("foo-1.0")} (at master@#{ref[0, 7]})"
expect(the_bundle).to include_gems "foo 1.0"
end
end
Expand Down
6 changes: 4 additions & 2 deletions spec/install/gemfile/eval_gemfile_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@
eval_gemfile 'Gemfile-other'
G
expect(out).to include("Resolving dependencies")
expect(out).to include("Using gunks 0.0.1 from source at `gems/gunks`")
expect(out).to include("Bundle complete")

expect(the_bundle).to include_gem "gunks 0.0.1", :source => "path@#{bundled_app("gems", "gunks")}"
end
end

Expand Down Expand Up @@ -52,8 +53,9 @@
gemspec :path => 'gems/gunks'
G
expect(out).to include("Resolving dependencies")
expect(out).to include("Using gunks 0.0.1 from source at `gems/gunks`")
expect(out).to include("Bundle complete")

expect(the_bundle).to include_gem "gunks 0.0.1", :source => "path@#{bundled_app("gems", "gunks")}"
end
end
end
5 changes: 2 additions & 3 deletions spec/install/gemfile/git_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -397,9 +397,8 @@
gem "rack", :git => "#{lib_path("rack-0.8")}", :branch => "master"
G

bundle %(config local.rack #{lib_path("local-rack")})
bundle :install
expect(out).to match(/at #{lib_path('local-rack')}/)
bundle! %(config local.rack #{lib_path("local-rack")})
bundle! :install

run "require 'rack'"
expect(out).to eq("LOCAL")
Expand Down
1 change: 0 additions & 1 deletion spec/install/gems/native_extensions_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@
G

expect(out).not_to include("extconf.rb failed")
expect(out).to include("Using c_extension 1.0")

run! "Bundler.require; puts CExtension.new.its_true"
expect(out).to eq("true")
Expand Down
4 changes: 2 additions & 2 deletions spec/install/git_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

RSpec.describe "bundle install" do
context "git sources" do
it "displays the revision hash of the gem repository" do
it "displays the revision hash of the gem repository", :bundler => "< 2" do
build_git "foo", "1.0", :path => lib_path("foo")

install_gemfile <<-G
Expand All @@ -14,7 +14,7 @@
expect(the_bundle).to include_gems "foo 1.0", :source => "git@#{lib_path("foo")}"
end

it "displays the ref of the gem repository when using branch~num as a ref" do
it "displays the ref of the gem repository when using branch~num as a ref", :bundler => "< 2" do
build_git "foo", "1.0", :path => lib_path("foo")
rev = revision_for(lib_path("foo"))[0..6]
update_git "foo", "2.0", :path => lib_path("foo"), :gemspec => true
Expand Down
9 changes: 3 additions & 6 deletions spec/runtime/setup_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -529,8 +529,7 @@ def clean_load_path(lp)
G

bundle %(config local.rack #{lib_path("local-rack")})
bundle :install
expect(out).to match(/at #{lib_path('local-rack')}/)
bundle! :install

FileUtils.rm_rf(lib_path("local-rack"))
run "require 'rack'"
Expand All @@ -548,8 +547,7 @@ def clean_load_path(lp)
G

bundle %(config local.rack #{lib_path("local-rack")})
bundle :install
expect(out).to match(/at #{lib_path('local-rack')}/)
bundle! :install

gemfile <<-G
source "file://#{gem_repo1}"
Expand All @@ -571,8 +569,7 @@ def clean_load_path(lp)
G

bundle %(config local.rack #{lib_path("local-rack")})
bundle :install
expect(out).to match(/at #{lib_path('local-rack')}/)
bundle! :install

gemfile <<-G
source "file://#{gem_repo1}"
Expand Down
5 changes: 2 additions & 3 deletions spec/update/git_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,11 @@
s.add_dependency "activesupport", "= 3.0"
end

install_gemfile <<-G
install_gemfile! <<-G
gem "rails", :git => "#{lib_path("rails")}"
G

bundle "update rails"
expect(out).to include("Using activesupport 3.0 from #{lib_path("rails")} (at master@#{revision_for(lib_path("rails"))[0..6]})")
bundle! "update rails"
expect(the_bundle).to include_gems "rails 3.0", "activesupport 3.0"
end

Expand Down