Skip to content

Commit ac98107

Browse files
Fix Bundler printing more flags than actually passed in verbose mode
This reverts commit bea87ea and adds a regression spec for it.
1 parent 76abc01 commit ac98107

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

bundler/lib/bundler/cli.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,12 @@ def print_command
713713
command_name = cmd.name
714714
return if PARSEABLE_COMMANDS.include?(command_name)
715715
command = ["bundle", command_name] + args
716-
command << Thor::Options.to_switches(options.sort_by(&:first)).strip
716+
options_to_print = options.dup
717+
options_to_print.delete_if do |k, v|
718+
next unless o = cmd.options[k]
719+
o.default == v
720+
end
721+
command << Thor::Options.to_switches(options_to_print.sort_by(&:first)).strip
717722
command.reject!(&:empty?)
718723
Bundler.ui.info "Running `#{command * " "}` with bundler #{Bundler.verbose_version}"
719724
end

bundler/spec/commands/list_spec.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
# frozen_string_literal: true
22

33
RSpec.describe "bundle list" do
4+
context "in verbose mode" do
5+
it "logs the actual flags passed to the command" do
6+
install_gemfile <<-G
7+
source "https://gem.repo1"
8+
G
9+
10+
bundle "list --verbose"
11+
12+
expect(out).to include("Running `bundle list --verbose`")
13+
end
14+
end
15+
416
context "with name-only and paths option" do
517
it "raises an error" do
618
bundle "list --name-only --paths", raise_on_error: false

0 commit comments

Comments
 (0)