summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Rodríguez <deivid.rodriguez@riseup.net>2025-04-10 20:32:25 +0200
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2025-04-14 16:17:50 +0900
commit38024772cafb3342a61d247c42d47d07afa97a8a (patch)
treebcea82d64eb8bef2921aa5f0df295060e5c9e4c1
parentce2640dde8c65d9e11c3bc2249c5cd5bb7d0dbce (diff)
[rubygems/rubygems] Refine `bundle update --verbose` logs
Don't mention "Found changes from the lockfile" because that's not really true in general. https://github.com/rubygems/rubygems/commit/0181c278e8
-rw-r--r--lib/bundler/definition.rb55
-rw-r--r--spec/bundler/commands/update_spec.rb17
2 files changed, 54 insertions, 18 deletions
diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb
index a442ea62cc..631fda91c9 100644
--- a/lib/bundler/definition.rb
+++ b/lib/bundler/definition.rb
@@ -337,11 +337,7 @@ module Bundler
end
end
else
- if lockfile_exists?
- Bundler.ui.debug "Found changes from the lockfile, re-resolving dependencies because #{change_reason}"
- else
- Bundler.ui.debug "Resolving dependencies because there's no lockfile"
- end
+ Bundler.ui.debug resolve_needed_reason
start_resolution
end
@@ -537,9 +533,7 @@ module Bundler
return unless added.any? || deleted.any? || changed.any? || resolve_needed?
- reason = resolve_needed? ? change_reason : "some dependencies were deleted from your gemfile"
-
- msg = String.new("#{reason.capitalize.strip}, but ")
+ msg = String.new("#{change_reason.capitalize.strip}, but ")
msg << "the lockfile " unless msg.start_with?("Your lockfile")
msg << "can't be updated because #{update_refused_reason}"
msg << "\n\nYou have added to the Gemfile:\n" << added.join("\n") if added.any?
@@ -796,22 +790,47 @@ module Bundler
@most_specific_locked_platform
end
- def change_reason
- if unlocking?
- unlock_targets = if @gems_to_unlock.any?
- ["gems", @gems_to_unlock]
- elsif @sources_to_unlock.any?
- ["sources", @sources_to_unlock]
+ def resolve_needed_reason
+ if lockfile_exists?
+ if unlocking?
+ "Re-resolving dependencies because #{unlocking_reason}"
+ else
+ "Found changes from the lockfile, re-resolving dependencies because #{lockfile_changed_reason}"
end
+ else
+ "Resolving dependencies because there's no lockfile"
+ end
+ end
- unlock_reason = if unlock_targets
- "#{unlock_targets.first}: (#{unlock_targets.last.join(", ")})"
+ def change_reason
+ if resolve_needed?
+ if unlocking?
+ unlocking_reason
else
- @unlocking_ruby ? "ruby" : ""
+ lockfile_changed_reason
end
+ else
+ "some dependencies were deleted from your gemfile"
+ end
+ end
- return "bundler is unlocking #{unlock_reason}"
+ def unlocking_reason
+ unlock_targets = if @gems_to_unlock.any?
+ ["gems", @gems_to_unlock]
+ elsif @sources_to_unlock.any?
+ ["sources", @sources_to_unlock]
end
+
+ unlock_reason = if unlock_targets
+ "#{unlock_targets.first}: (#{unlock_targets.last.join(", ")})"
+ else
+ @unlocking_ruby ? "ruby" : ""
+ end
+
+ "bundler is unlocking #{unlock_reason}"
+ end
+
+ def lockfile_changed_reason
[
[@source_changes, "the list of sources changed"],
[@dependency_changes, "the dependencies in your gemfile changed"],
diff --git a/spec/bundler/commands/update_spec.rb b/spec/bundler/commands/update_spec.rb
index c6ab0dcf14..cccf446561 100644
--- a/spec/bundler/commands/update_spec.rb
+++ b/spec/bundler/commands/update_spec.rb
@@ -39,6 +39,23 @@ RSpec.describe "bundle update" do
end
end
+ describe "with --verbose" do
+ before do
+ build_repo2
+
+ install_gemfile <<~G
+ source "https://gem.repo2"
+ gem "myrack"
+ G
+ end
+
+ it "logs the reason for re-resolving" do
+ bundle "update --verbose"
+ expect(out).not_to include("Found changes from the lockfile")
+ expect(out).to include("Re-resolving dependencies because bundler is unlocking")
+ end
+ end
+
describe "with --all" do
before do
build_repo2