Include installed gem version plugin information. Clean after install and update.

This commit is contained in:
Chris Roberts 2016-11-16 13:19:43 -08:00
parent fb85bb1c7b
commit 06e1b2f52c
2 changed files with 28 additions and 7 deletions

View File

@ -80,9 +80,13 @@ module Vagrant
version: opts[:version],
require: opts[:require],
sources: opts[:sources],
installed_gem_version: result.version
installed_gem_version: result.version.to_s
)
# After install clean plugin gems to remove any cruft. This is useful
# for removing outdated dependencies or other versions of an installed
# plugin if the plugin is upgraded/downgraded
Vagrant::Bundler.instance.clean(installed_plugins)
result
rescue Gem::GemNotFoundException
raise Errors::PluginGemNotFound, name: name
@ -111,7 +115,23 @@ module Vagrant
# Updates all or a specific set of plugins.
def update_plugins(specific)
Vagrant::Bundler.instance.update(installed_plugins, specific)
result = Vagrant::Bundler.instance.update(installed_plugins, specific)
installed_plugins.each do |name, info|
matching_spec = result.detect{|s| s.name == name}
info = Hash[
info.map do |key, value|
[key.to_sym, value]
end
]
if matching_spec
@user_file.add_plugin(name, **info.merge(
version: "> 0",
installed_gem_version: matching_spec.version.to_s
))
end
end
Vagrant::Bundler.instance.clean(installed_plugins)
result
rescue Gem::Exception => e
raise Errors::BundlerError, message: e.to_s
end

View File

@ -31,11 +31,12 @@ module Vagrant
# @param [String] name The name of the plugin
def add_plugin(name, **opts)
@data["installed"][name] = {
"ruby_version" => RUBY_VERSION,
"vagrant_version" => Vagrant::VERSION,
"gem_version" => opts[:version] || "",
"require" => opts[:require] || "",
"sources" => opts[:sources] || [],
"ruby_version" => RUBY_VERSION,
"vagrant_version" => Vagrant::VERSION,
"gem_version" => opts[:version] || "",
"require" => opts[:require] || "",
"sources" => opts[:sources] || [],
"installed_gem_version" => opts[:installed_gem_version]
}
save!