Merge pull request #6893 from mmickan/prerelease-version-fix
Prerelease version fix
This commit is contained in:
commit
27157b5408
|
@ -276,17 +276,16 @@ module Vagrant
|
|||
next if versiondir.basename.to_s.start_with?(".")
|
||||
|
||||
version = versiondir.basename.to_s
|
||||
Gem::Version.new(version)
|
||||
end.compact
|
||||
|
||||
# Traverse through versions with the latest version first
|
||||
versions.sort.reverse.each do |v|
|
||||
if !requirements.all? { |r| r.satisfied_by?(v) }
|
||||
if !requirements.all? { |r| r.satisfied_by?(Gem::Version.new(v)) }
|
||||
# Unsatisfied version requirements
|
||||
next
|
||||
end
|
||||
|
||||
versiondir = box_directory.join(v.to_s)
|
||||
versiondir = box_directory.join(v)
|
||||
providers.each do |provider|
|
||||
provider_dir = versiondir.join(provider.to_s)
|
||||
next if !provider_dir.directory?
|
||||
|
@ -303,7 +302,7 @@ module Vagrant
|
|||
end
|
||||
|
||||
return Box.new(
|
||||
name, provider, v.to_s, provider_dir,
|
||||
name, provider, v, provider_dir,
|
||||
metadata_url: metadata_url,
|
||||
)
|
||||
end
|
||||
|
|
|
@ -194,6 +194,19 @@ describe Vagrant::BoxCollection, :skip_windows do
|
|||
expect(result.version).to eq("1.0")
|
||||
end
|
||||
|
||||
it "handles prerelease versions" do
|
||||
# Create the "box"
|
||||
environment.box3("foo", "0.1.0-alpha.1", :virtualbox)
|
||||
environment.box3("foo", "0.1.0-alpha.2", :virtualbox)
|
||||
|
||||
# Actual test
|
||||
result = subject.find("foo", :virtualbox, ">= 0")
|
||||
expect(result).to_not be_nil
|
||||
expect(result).to be_kind_of(box_class)
|
||||
expect(result.name).to eq("foo")
|
||||
expect(result.version).to eq("0.1.0-alpha.2")
|
||||
end
|
||||
|
||||
it "returns nil if a box's constraints can't be satisfied" do
|
||||
# Create the "box"
|
||||
environment.box3("foo", "0.1", :virtualbox)
|
||||
|
|
Loading…
Reference in New Issue