Deep merge plugin list with system plugins. Discard specifications correctly.

This commit is contained in:
Chris Roberts 2017-06-27 17:16:50 -07:00
parent f45bd527e1
commit 97715280c2
2 changed files with 15 additions and 4 deletions

View File

@ -146,7 +146,7 @@ module Vagrant
system[k] = v.merge("system" => true)
end
end
plugin_list = system.merge(@user_file.installed_plugins)
plugin_list = Util::DeepMerge.deep_merge(system, @user_file.installed_plugins)
# Sort plugins by name
Hash[
@ -161,7 +161,15 @@ module Vagrant
#
# @return [Array<Gem::Specification>]
def installed_specs
installed = Set.new(installed_plugins.keys)
installed_plugin_info = installed_plugins
installed = Set.new(installed_plugin_info.keys)
installed_versions = Hash[
installed_plugin_info.map{|plugin_name, plugin_info|
gem_version = plugin_info["gem_version"].to_s
gem_version = "> 0" if gem_version.empty?
[plugin_name, Gem::Requirement.new(gem_version)]
}
]
# Go through the plugins installed in this environment and
# get the latest version of each.
@ -170,6 +178,9 @@ module Vagrant
# Ignore specs that aren't in our installed list
next if !installed.include?(spec.name)
next if installed_versions[spec.name] &&
!installed_versions[spec.name].satisfied_by?(spec.version)
# If we already have a newer version in our list of installed,
# then ignore it
next if installed_map.key?(spec.name) &&

View File

@ -4,7 +4,7 @@ require "pathname"
require "vagrant/plugin"
require "vagrant/plugin/manager"
require "vagrant/plugin/state_file"
require "vagrant/util/deep_merge"
require File.expand_path("../../../base", __FILE__)
describe Vagrant::Plugin::Manager do
@ -243,7 +243,7 @@ describe Vagrant::Plugin::Manager do
expect(plugins.length).to eql(2)
expect(plugins).to have_key("foo")
expect(plugins["foo"]["gem_version"]).to eq("0.1.0")
expect(plugins["foo"]["system"]).to be_false
expect(plugins["foo"]["system"]).to be_true
expect(plugins).to have_key("bar")
expect(plugins["bar"]["system"]).to be_true
end