diff options
| author | Ellen Marie Dash <me@duckie.co> | 2024-09-27 21:13:00 -0400 |
|---|---|---|
| committer | git <svn-admin@ruby-lang.org> | 2024-09-28 21:12:25 +0000 |
| commit | 47a3482a414013bdbbcb9da4bc3bea7451977009 (patch) | |
| tree | 2bf40d8f1487d4f9d4a8f1beca20194ec1ac8d3a | |
| parent | b9e225fcbfd045e65f1a95bcef16d97cbfb97287 (diff) | |
[rubygems/rubygems] Remove code that makes suggest_gems_from_name give worse results.
https://github.com/rubygems/rubygems/commit/09ec67ffdf
| -rw-r--r-- | lib/rubygems/spec_fetcher.rb | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/lib/rubygems/spec_fetcher.rb b/lib/rubygems/spec_fetcher.rb index 610edf25c9..9c0399f196 100644 --- a/lib/rubygems/spec_fetcher.rb +++ b/lib/rubygems/spec_fetcher.rb @@ -176,19 +176,12 @@ class Gem::SpecFetcher matches = names.map do |n| next unless n.match_platform? - [n.name, 0] if n.name.downcase.tr("_-", "").include?(gem_name) + distance = levenshtein_distance gem_name, n.name.downcase.tr("_-", "") + next if distance >= max + return [n.name] if distance == 0 + [n.name, distance] end.compact - if matches.length < num_results - matches += names.map do |n| - next unless n.match_platform? - distance = levenshtein_distance gem_name, n.name.downcase.tr("_-", "") - next if distance >= max - return [n.name] if distance == 0 - [n.name, distance] - end.compact - end - matches = if matches.empty? && type != :prerelease suggest_gems_from_name gem_name, :prerelease else |
