core: box names with colons work on Windows [GH-4100]

This commit is contained in:
Mitchell Hashimoto 2014-08-08 14:47:17 -07:00
parent 27bf597214
commit 15f1823d5c
3 changed files with 12 additions and 4 deletions

View File

@ -26,6 +26,7 @@ BUG FIXES:
- core: Fix encoding issues with Windows. There are still some outlying
but this fixes a few. [GH-4159]
- core: Fix crash case when destroying with an invalid provisioner. [GH-4281]
- core: Box names with colons work on Windows. [GH-4100]
- commands/package: base package won't crash with exception [GH-4017]
- commands/rsync-auto: Destroyed machines won't raise exceptions. [GH-4031]
- communicators/ssh: Nicer error if remote unexpectedly disconects. [GH-4038]

View File

@ -4,6 +4,7 @@ require "tmpdir"
require "log4r"
require "vagrant/util/platform"
require "vagrant/util/subprocess"
module Vagrant
@ -349,12 +350,18 @@ module Vagrant
# @param [String] name
# @return [String]
def dir_name(name)
name.gsub("/", "-VAGRANTSLASH-")
name = name.dup
name.gsub!(":", "-VAGRANTCOLON-") if Util::Platform.windows?
name.gsub!("/", "-VAGRANTSLASH-")
name
end
# Returns the directory name for the box cleaned up
def undir_name(name)
name.gsub("-VAGRANTSLASH-", "/")
name = name.dup
name.gsub!("-VAGRANTCOLON-", ":")
name.gsub!("-VAGRANTSLASH-", "/")
name
end
# This checks if the given directory represents a V1 box on the

View File

@ -26,7 +26,7 @@ describe Vagrant::BoxCollection do
environment.box3("foo", "1.0", :vmware)
environment.box3("bar", "0", :ec2)
environment.box3("foo-VAGRANTSLASH-bar", "1.0", :virtualbox)
environment.box3("foo:bar", "1.0", :virtualbox)
environment.box3("foo-VAGRANTCOLON-colon", "1.0", :virtualbox)
# Verify some output
results = subject.all
@ -35,7 +35,7 @@ describe Vagrant::BoxCollection do
expect(results.include?(["foo", "1.0", :vmware])).to be
expect(results.include?(["bar", "0", :ec2])).to be
expect(results.include?(["foo/bar", "1.0", :virtualbox])).to be
expect(results.include?(["foo:bar", "1.0", :virtualbox])).to be
expect(results.include?(["foo:colon", "1.0", :virtualbox])).to be
end
it 'does not raise an exception when a file appears in the boxes dir' do