Merge pull request #8341 from chrisroberts/enhancement/prerelease

Support spec prerelease matching
This commit is contained in:
Chris Roberts 2017-03-07 15:02:17 -08:00 committed by GitHub
commit 9d1ec938ef
3 changed files with 27 additions and 3 deletions

View File

@ -284,7 +284,10 @@ module Vagrant
# as we know the dependencies are satisfied and it will attempt to validate a gem's # as we know the dependencies are satisfied and it will attempt to validate a gem's
# dependencies are satisified by gems in the install directory (which will likely not # dependencies are satisified by gems in the install directory (which will likely not
# be true) # be true)
result = request_set.install_into(plugin_gem_path.to_s, true, ignore_dependencies: true) result = request_set.install_into(plugin_gem_path.to_s, true,
ignore_dependencies: true,
prerelease: Vagrant.prerelease?
)
result = result.map(&:full_spec) result = result.map(&:full_spec)
result result
end end
@ -437,7 +440,8 @@ module Vagrant
def find_all(req) def find_all(req)
@specs.select do |spec| @specs.select do |spec|
req.match?(spec) allow_prerelease = spec.name == "vagrant" && Vagrant.prerelease?
req.match?(spec, allow_prerelease)
end.map do |spec| end.map do |spec|
Gem::Resolver::InstalledSpecification.new(self, spec) Gem::Resolver::InstalledSpecification.new(self, spec)
end end
@ -486,7 +490,7 @@ module Vagrant
# ignored. # ignored.
def load_spec (name, version, platform, source) def load_spec (name, version, platform, source)
version = Gem::Version.new(version) if !version.is_a?(Gem::Version) version = Gem::Version.new(version) if !version.is_a?(Gem::Version)
@specs.fetch(name, []).detect{|s| s.name == name && s.version = version} @specs.fetch(name, []).detect{|s| s.name == name && s.version == version}
end end
end end
end end

View File

@ -102,4 +102,12 @@ module Vagrant
Pathname.new(path).expand_path Pathname.new(path).expand_path
end end
# This returns true/false if the running version of Vagrant is
# a pre-release version (development)
#
# @return [Boolean]
def self.prerelease?
Gem::Version.new(Vagrant::VERSION).prerelease?
end
end end

View File

@ -131,4 +131,16 @@ describe Vagrant do
end end
end end
end end
describe "#prerelease?" do
it "should return true when Vagrant version is development" do
stub_const("Vagrant::VERSION", "1.0.0.dev")
expect(subject.prerelease?).to be(true)
end
it "should return false when Vagrant version is release" do
stub_const("Vagrant::VERSION", "1.0.0")
expect(subject.prerelease?).to be(false)
end
end
end end