summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Rodríguez <deivid.rodriguez@riseup.net>2025-08-08 12:42:16 +0200
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2025-08-18 12:31:51 +0900
commit8d5f00c5371ff71f33ef57b1419fd8d4b1aa9074 (patch)
tree9afc51439af6889c62bd7b97105e368e114c37f5
parentf074f8260aae2cb541d13f87a990404038c1b6e5 (diff)
[rubygems/rubygems] Fix Bundler printing more flags than actually passed in verbose mode
This reverts commit https://github.com/rubygems/rubygems/commit/bea87eab0b17 and adds a regression spec for it. https://github.com/rubygems/rubygems/commit/ac98107864
-rw-r--r--lib/bundler/cli.rb7
-rw-r--r--spec/bundler/commands/list_spec.rb12
2 files changed, 18 insertions, 1 deletions
diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb
index 23c20fc7b3..8c4e3c36a7 100644
--- a/lib/bundler/cli.rb
+++ b/lib/bundler/cli.rb
@@ -714,7 +714,12 @@ module Bundler
command_name = cmd.name
return if PARSEABLE_COMMANDS.include?(command_name)
command = ["bundle", command_name] + args
- command << Thor::Options.to_switches(options.sort_by(&:first)).strip
+ options_to_print = options.dup
+ options_to_print.delete_if do |k, v|
+ next unless o = cmd.options[k]
+ o.default == v
+ end
+ command << Thor::Options.to_switches(options_to_print.sort_by(&:first)).strip
command.reject!(&:empty?)
Bundler.ui.info "Running `#{command * " "}` with bundler #{Bundler.verbose_version}"
end
diff --git a/spec/bundler/commands/list_spec.rb b/spec/bundler/commands/list_spec.rb
index cc0db9169d..e8ed863310 100644
--- a/spec/bundler/commands/list_spec.rb
+++ b/spec/bundler/commands/list_spec.rb
@@ -1,6 +1,18 @@
# frozen_string_literal: true
RSpec.describe "bundle list" do
+ context "in verbose mode" do
+ it "logs the actual flags passed to the command" do
+ install_gemfile <<-G
+ source "https://gem.repo1"
+ G
+
+ bundle "list --verbose"
+
+ expect(out).to include("Running `bundle list --verbose`")
+ end
+ end
+
context "with name-only and paths option" do
it "raises an error" do
bundle "list --name-only --paths", raise_on_error: false