diff options
author | yuuji.yaginuma <yuuji.yaginuma@gmail.com> | 2018-10-15 07:55:42 +0900 |
---|---|---|
committer | yuuji.yaginuma <yuuji.yaginuma@gmail.com> | 2018-10-15 07:55:42 +0900 |
commit | 9d834e68c553578006b2ff414ffc96514b9aa2f5 (patch) | |
tree | d4beed6c5f2b437e2213fbac54ffaa0168a23a4f | |
parent | 27e88538960817a64a510f840c810654f1a7fa3e (diff) | |
download | bundler-9d834e68c553578006b2ff414ffc96514b9aa2f5.tar.gz |
Remove the duplicate gems from suggestions
If the lock file has the same gems for different platforms, the
suggestion includes all those gems.
For example, using the Rails's lock file(https://github.com/rails/rails/blob/4a51cbba58435bbba65ca50670bd6ae4887942bd/Gemfile.lock),
it shows like this:
```
$ bundle update mai
Could not find gem 'mai'.
Did you mean ffi, ffi, ffi, ffi, mail, ast, jwt, que or wdm?
```
Since it is unnecessary to include the same gem, removed duplicate gems.
-rw-r--r-- | lib/bundler/cli/common.rb | 2 | ||||
-rw-r--r-- | spec/commands/update_spec.rb | 5 |
2 files changed, 4 insertions, 3 deletions
diff --git a/lib/bundler/cli/common.rb b/lib/bundler/cli/common.rb index 8084405b38..09a1753337 100644 --- a/lib/bundler/cli/common.rb +++ b/lib/bundler/cli/common.rb @@ -72,7 +72,7 @@ module Bundler end def self.ensure_all_gems_in_lockfile!(names, locked_gems = Bundler.locked_gems) - locked_names = locked_gems.specs.map(&:name) + locked_names = locked_gems.specs.map(&:name).uniq names.-(locked_names).each do |g| raise GemNotFound, gem_not_found_message(g, locked_names) end diff --git a/spec/commands/update_spec.rb b/spec/commands/update_spec.rb index 6eb49d3acd..6f29032dd2 100644 --- a/spec/commands/update_spec.rb +++ b/spec/commands/update_spec.rb @@ -8,6 +8,7 @@ RSpec.describe "bundle update" do source "file://#{gem_repo2}" gem "activesupport" gem "rack-obama" + gem "platform_specific" G end @@ -116,8 +117,8 @@ RSpec.describe "bundle update" do expect(out).to include "Could not find gem 'halting-problem-solver'" end it "should suggest alternatives" do - bundle "update active-support" - expect(out).to include "Did you mean activesupport?" + bundle "update platformspecific" + expect(out).to include "Did you mean platform_specific?" end end |