diff options
author | The Bundler Bot <bot@bundler.io> | 2018-08-15 02:47:39 +0000 |
---|---|---|
committer | Colby Swandale <hello@colby.fyi> | 2018-08-16 21:43:33 +1000 |
commit | c93b99887505c54782699770e9b69d7462a25141 (patch) | |
tree | 7dd424626ec80b2be44cc5a0fea4ebf84ecb56b7 | |
parent | b98b55850aaf5405703442c1a2e5b49ca82ba982 (diff) | |
download | bundler-c93b99887505c54782699770e9b69d7462a25141.tar.gz |
Auto merge of #6650 - greysteil:dont-mutate-original-trees, r=segiddins
Don't mutate original error trees when determining version_conflict_message
*I know I'm messing with private APIs here, so have no right to expect this PR merged!*
Currently, when Bundler generates its error message for a version conflict, it mutates the `requirement_trees` array on the underlying `Molinillo::VersionConflict` error.
I would really like it if it didn't. Dependabot taps into that error to understand what went wrong with resolution and unlock any dependencies that are blocking resolution. The code where we do so is [here](https://github.com/dependabot/dependabot-core/blob/9abcb85ba69b408b11b56572dd13ab89d0c55b8c/lib/dependabot/file_updaters/ruby/bundler/lockfile_updater.rb#L142-L167).
I don't think that there's any downside to not mutating here. Resolution has finished (and failed) at this stage, so trying to reduce memory usage doesn't really matter.
🙏
(cherry picked from commit fc60fe4362a23254602fd4082a8d63ec5daf8106)
-rw-r--r-- | lib/bundler/resolver.rb | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/bundler/resolver.rb b/lib/bundler/resolver.rb index f8cb1a34c3..fdef32abf6 100644 --- a/lib/bundler/resolver.rb +++ b/lib/bundler/resolver.rb @@ -302,6 +302,9 @@ module Bundler :solver_name => "Bundler", :possibility_type => "gem", :reduce_trees => lambda do |trees| + # called first, because we want to reduce the amount of work required to find maximal empty sets + trees = trees.uniq {|t| t.flatten.map {|dep| [dep.name, dep.requirement] } } + # bail out if tree size is too big for Array#combination to make any sense return trees if trees.size > 15 maximal = 1.upto(trees.size).map do |size| |