Show the correct installed plugin [GH-1834]

This commit is contained in:
Mitchell Hashimoto 2013-07-28 21:38:48 -07:00
parent 45fb5d40b6
commit e1c0c48ffa
2 changed files with 16 additions and 1 deletions

View File

@ -9,6 +9,8 @@ BUG FIXES:
- Make sure the hostname configuration is a string. [GH-1999] - Make sure the hostname configuration is a string. [GH-1999]
- cURL downloads now contain a user agent which fixes some - cURL downloads now contain a user agent which fixes some
issues with downloading Vagrant through proxies. [GH-2003] issues with downloading Vagrant through proxies. [GH-2003]
- `vagrant plugin install` will now always properly show the actual
installed gem name. [GH-1834]
## 1.2.6 (July 26, 2013) ## 1.2.6 (July 26, 2013)

View File

@ -1,5 +1,6 @@
require "rubygems" require "rubygems"
require "rubygems/dependency_installer" require "rubygems/dependency_installer"
require "rubygems/format"
require "log4r" require "log4r"
@ -19,6 +20,16 @@ module VagrantPlugins
prerelease = env[:plugin_prerelease] prerelease = env[:plugin_prerelease]
version = env[:plugin_version] version = env[:plugin_version]
# Determine the plugin name we'll look for in the installed set
# in order to determine the version and all that.
find_plugin_name = plugin_name
if plugin_name =~ /\.gem$/
# If we're installing from a gem file, determine the name
# based on the spec in the file.
pkg = Gem::Format.from_file_by_path(plugin_name)
find_plugin_name = pkg.spec.name
end
# Install the gem # Install the gem
plugin_name_label = plugin_name plugin_name_label = plugin_name
plugin_name_label += ' --prerelease' if prerelease plugin_name_label += ' --prerelease' if prerelease
@ -45,7 +56,9 @@ module VagrantPlugins
# The plugin spec is the last installed gem since RubyGems # The plugin spec is the last installed gem since RubyGems
# currently always installed the requested gem last. # currently always installed the requested gem last.
@logger.debug("Installed #{installed_gems.length} gems.") @logger.debug("Installed #{installed_gems.length} gems.")
plugin_spec = installed_gems.last plugin_spec = installed_gems.find do |gem|
gem.name.downcase == find_plugin_name.downcase
end
# Store the installed name so we can uninstall it if things go # Store the installed name so we can uninstall it if things go
# wrong. # wrong.