Skip to content

Commit 158e4cc

Browse files
deivid-rodriguezhsbt
authored andcommitted
[rubygems/rubygems] Improve log message about adding a new platform
This message is printed when running `bundle lock --add-platform`. This command affects the lockfile, not the gemfile, and I think it's better to use "You are adding" rather than "You added", because the addition is happening during the current invocation (as opposed to other log messages that talk about a change made to the Gemfile prior to running the command). ruby/rubygems@aba1e55f5b
1 parent 5284719 commit 158e4cc

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

lib/bundler/definition.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,7 @@ def resolution_packages
623623
@resolution_packages ||= begin
624624
last_resolve = converge_locked_specs
625625
remove_invalid_platforms!
626-
new_resolution_platforms = @current_platform_missing ? @new_platforms.append(local_platform) : @new_platforms
626+
new_resolution_platforms = @current_platform_missing ? @new_platforms + [local_platform] : @new_platforms
627627
packages = Resolver::Base.new(source_requirements, expanded_dependencies, last_resolve, @platforms, locked_specs: @originally_locked_specs, unlock: @unlocking_all || @gems_to_unlock, prerelease: gem_version_promoter.pre?, prefer_local: @prefer_local, new_platforms: new_resolution_platforms)
628628
packages = additional_base_requirements_to_prevent_downgrades(packages)
629629
packages = additional_base_requirements_to_force_updates(packages)
@@ -797,7 +797,7 @@ def change_reason
797797
[@source_changes, "the list of sources changed"],
798798
[@dependency_changes, "the dependencies in your gemfile changed"],
799799
[@current_platform_missing, "your lockfile does not include the current platform"],
800-
[@new_platforms.any?, "you added a new platform to your gemfile"],
800+
[@new_platforms.any?, "you are adding a new platform to your lockfile"],
801801
[@path_changes, "the gemspecs for path gems changed"],
802802
[@local_changes, "the gemspecs for git local gems changed"],
803803
[@missing_lockfile_dep, "your lock file is missing \"#{@missing_lockfile_dep}\""],

spec/bundler/commands/install_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1369,7 +1369,7 @@ def run
13691369
bundle "install --verbose"
13701370

13711371
expect(out).to include("re-resolving dependencies because your lockfile does not include the current platform")
1372-
expect(out).not_to include("you added a new platform to your gemfile")
1372+
expect(out).not_to include("you are adding a new platform to your lockfile")
13731373

13741374
expect(lockfile).to eq <<~L
13751375
GEM

spec/bundler/commands/lock_spec.rb

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -761,8 +761,18 @@
761761
expect(lockfile).to end_with("BUNDLED WITH\n 99\n")
762762
end
763763

764-
it "supports adding new platforms" do
765-
bundle "lock --add-platform java x86-mingw32"
764+
it "supports adding new platforms when there's no previous lockfile" do
765+
bundle "lock --add-platform java x86-mingw32 --verbose"
766+
expect(out).to include("Resolving dependencies because there's no lockfile")
767+
768+
allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile)
769+
expect(the_bundle.locked_platforms).to match_array(default_platform_list("java", "x86-mingw32"))
770+
end
771+
772+
it "supports adding new platforms when a previous lockfile exists" do
773+
bundle "lock"
774+
bundle "lock --add-platform java x86-mingw32 --verbose"
775+
expect(out).to include("Found changes from the lockfile, re-resolving dependencies because you are adding a new platform to your lockfile")
766776

767777
allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile)
768778
expect(the_bundle.locked_platforms).to match_array(default_platform_list("java", "x86-mingw32"))

0 commit comments

Comments
 (0)