diff options
-rw-r--r-- | lib/bundler/feature_flag.rb | 1 | ||||
-rw-r--r-- | lib/bundler/settings.rb | 1 | ||||
-rw-r--r-- | lib/bundler/source.rb | 8 | ||||
-rw-r--r-- | lib/bundler/source/git.rb | 2 | ||||
-rw-r--r-- | lib/bundler/source/path.rb | 2 | ||||
-rw-r--r-- | lib/bundler/source/rubygems.rb | 2 | ||||
-rw-r--r-- | man/bundle-config.ronn | 3 | ||||
-rw-r--r-- | spec/commands/update_spec.rb | 34 |
8 files changed, 50 insertions, 3 deletions
diff --git a/lib/bundler/feature_flag.rb b/lib/bundler/feature_flag.rb index f2671015b3..3b28774258 100644 --- a/lib/bundler/feature_flag.rb +++ b/lib/bundler/feature_flag.rb @@ -37,6 +37,7 @@ module Bundler 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? } diff --git a/lib/bundler/settings.rb b/lib/bundler/settings.rb index f131a310b9..539aab4d1c 100644 --- a/lib/bundler/settings.rb +++ b/lib/bundler/settings.rb @@ -35,6 +35,7 @@ module Bundler prefer_gems_rb silence_root_warning skip_default_git_sources + suppress_install_using_messages unlock_source_unlocks_spec update_requires_all_flag ].freeze diff --git a/lib/bundler/source.rb b/lib/bundler/source.rb index cb5f2da83e..f3d50adecf 100644 --- a/lib/bundler/source.rb +++ b/lib/bundler/source.rb @@ -60,5 +60,13 @@ module Bundler 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 diff --git a/lib/bundler/source/git.rb b/lib/bundler/source/git.rb index dc204a2b33..a5ece3d3d7 100644 --- a/lib/bundler/source/git.rb +++ b/lib/bundler/source/git.rb @@ -169,7 +169,7 @@ module Bundler 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}" diff --git a/lib/bundler/source/path.rb b/lib/bundler/source/path.rb index 99808d2ef2..84a98420a9 100644 --- a/lib/bundler/source/path.rb +++ b/lib/bundler/source/path.rb @@ -76,7 +76,7 @@ module Bundler 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 diff --git a/lib/bundler/source/rubygems.rb b/lib/bundler/source/rubygems.rb index 70f7819f3a..e76a00361a 100644 --- a/lib/bundler/source/rubygems.rb +++ b/lib/bundler/source/rubygems.rb @@ -106,7 +106,7 @@ module Bundler 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 diff --git a/man/bundle-config.ronn b/man/bundle-config.ronn index 4085d2726c..785229e59a 100644 --- a/man/bundle-config.ronn +++ b/man/bundle-config.ronn @@ -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. diff --git a/spec/commands/update_spec.rb b/spec/commands/update_spec.rb index a7d50502e3..70ced672dd 100644 --- a/spec/commands/update_spec.rb +++ b/spec/commands/update_spec.rb @@ -449,6 +449,40 @@ RSpec.describe "bundle update" do 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" + 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" + 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}" |