synced_folders/rsync: convert path to cygpath on Windows
This commit is contained in:
parent
285bda7a68
commit
73b72deb0a
|
@ -33,11 +33,19 @@ module Vagrant
|
||||||
# path on Windows machines in Cygwin.
|
# path on Windows machines in Cygwin.
|
||||||
#
|
#
|
||||||
# @return [String]
|
# @return [String]
|
||||||
def cygwin_windows_path(path)
|
def cygwin_windows_path(path, **opts)
|
||||||
return path if !cygwin?
|
return path if !cygwin? && !opts[:force]
|
||||||
|
|
||||||
process = Subprocess.execute("cygpath", "-w", "-l", "-a", path.to_s)
|
begin
|
||||||
process.stdout.chomp
|
# First try the real cygpath
|
||||||
|
process = Subprocess.execute("cygpath", "-w", "-l", "-a", path.to_s)
|
||||||
|
return process.stdout.chomp
|
||||||
|
rescue Errors::CommandUnavailableWindows
|
||||||
|
# Sometimes cygpath isn't available (msys). Instead, do what we
|
||||||
|
# can with bash tricks.
|
||||||
|
process = Subprocess.execute("bash", "-c", "cd #{path} && pwd")
|
||||||
|
return process.stdout.chomp
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# This checks if the filesystem is case sensitive. This is not a
|
# This checks if the filesystem is case sensitive. This is not a
|
||||||
|
|
|
@ -13,6 +13,12 @@ module VagrantPlugins
|
||||||
hostpath = File.expand_path(hostpath, machine.env.root_path)
|
hostpath = File.expand_path(hostpath, machine.env.root_path)
|
||||||
hostpath = Vagrant::Util::Platform.fs_real_path(hostpath).to_s
|
hostpath = Vagrant::Util::Platform.fs_real_path(hostpath).to_s
|
||||||
|
|
||||||
|
if Vagrant::Util::Platform.windows?
|
||||||
|
# rsync for Windows expects cygwin style paths
|
||||||
|
hostpath = Vagrant::Util::Platform.cygwin_windows_path(
|
||||||
|
hostpath, force: true)
|
||||||
|
end
|
||||||
|
|
||||||
# Connection information
|
# Connection information
|
||||||
username = ssh_info[:username]
|
username = ssh_info[:username]
|
||||||
host = ssh_info[:host]
|
host = ssh_info[:host]
|
||||||
|
|
|
@ -21,6 +21,11 @@ describe VagrantPlugins::SyncedFolderRSync::RsyncHelper do
|
||||||
|
|
||||||
before do
|
before do
|
||||||
machine.stub(guest: guest)
|
machine.stub(guest: guest)
|
||||||
|
|
||||||
|
# Don't do all the crazy Cygwin stuff
|
||||||
|
Vagrant::Util::Platform.stub(:cygwin_windows_path) do |path, **opts|
|
||||||
|
path
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#rsync_single" do
|
describe "#rsync_single" do
|
||||||
|
@ -44,6 +49,23 @@ describe VagrantPlugins::SyncedFolderRSync::RsyncHelper do
|
||||||
subject.rsync_single(machine, ssh_info, opts)
|
subject.rsync_single(machine, ssh_info, opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "doesn't call cygwin_windows_path on non-Windows" do
|
||||||
|
Vagrant::Util::Platform.stub(windows?: false)
|
||||||
|
Vagrant::Util::Platform.should_not_receive(:cygwin_windows_path)
|
||||||
|
subject.rsync_single(machine, ssh_info, opts)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "calls cygwin_windows_path on Windows" do
|
||||||
|
Vagrant::Util::Platform.stub(windows?: true)
|
||||||
|
Vagrant::Util::Platform.should_receive(:cygwin_windows_path).and_return("foo")
|
||||||
|
|
||||||
|
Vagrant::Util::Subprocess.should_receive(:execute).with do |*args|
|
||||||
|
expect(args[args.length - 3]).to eql("foo")
|
||||||
|
end
|
||||||
|
|
||||||
|
subject.rsync_single(machine, ssh_info, opts)
|
||||||
|
end
|
||||||
|
|
||||||
it "raises an error if the exit code is non-zero" do
|
it "raises an error if the exit code is non-zero" do
|
||||||
Vagrant::Util::Subprocess.stub(
|
Vagrant::Util::Subprocess.stub(
|
||||||
execute: Vagrant::Util::Subprocess::Result.new(1, "", ""))
|
execute: Vagrant::Util::Subprocess::Result.new(1, "", ""))
|
||||||
|
|
Loading…
Reference in New Issue