synced_folders/rsync: allow custom args [GH-3070]
This commit is contained in:
parent
75754019a9
commit
d4511131b4
|
@ -39,21 +39,23 @@ module VagrantPlugins
|
||||||
excludes += Array(opts[:exclude]).map(&:to_s) if opts[:exclude]
|
excludes += Array(opts[:exclude]).map(&:to_s) if opts[:exclude]
|
||||||
excludes.uniq!
|
excludes.uniq!
|
||||||
|
|
||||||
|
# Get the command-line arguments
|
||||||
|
args = nil
|
||||||
|
args = Array(opts[:args]) if opts[:args]
|
||||||
|
args ||= ["--verbose", "--archive", "--delete", "-z"]
|
||||||
|
|
||||||
# Build up the actual command to execute
|
# Build up the actual command to execute
|
||||||
command = [
|
command = [
|
||||||
"rsync",
|
"rsync",
|
||||||
"--verbose",
|
args,
|
||||||
"--archive",
|
|
||||||
"--delete",
|
|
||||||
"-z",
|
|
||||||
excludes.map { |e| ["--exclude", e] },
|
|
||||||
"-e", rsh,
|
"-e", rsh,
|
||||||
|
excludes.map { |e| ["--exclude", e] },
|
||||||
hostpath,
|
hostpath,
|
||||||
"#{username}@#{host}:#{guestpath}"
|
"#{username}@#{host}:#{guestpath}",
|
||||||
].flatten
|
].flatten
|
||||||
command_opts = {}
|
|
||||||
|
|
||||||
# The working directory should be the root path
|
# The working directory should be the root path
|
||||||
|
command_opts = {}
|
||||||
command_opts[:workdir] = machine.env.root_path.to_s
|
command_opts[:workdir] = machine.env.root_path.to_s
|
||||||
|
|
||||||
machine.ui.info(I18n.t(
|
machine.ui.info(I18n.t(
|
||||||
|
|
|
@ -151,5 +151,34 @@ describe VagrantPlugins::SyncedFolderRSync::RsyncHelper do
|
||||||
subject.rsync_single(machine, ssh_info, opts)
|
subject.rsync_single(machine, ssh_info, opts)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "custom arguments" do
|
||||||
|
it "uses the default arguments if not given" do
|
||||||
|
Vagrant::Util::Subprocess.should_receive(:execute).with do |*args|
|
||||||
|
expect(args[1]).to eq("--verbose")
|
||||||
|
expect(args[2]).to eq("--archive")
|
||||||
|
expect(args[3]).to eq("--delete")
|
||||||
|
|
||||||
|
expected = Vagrant::Util::Platform.fs_real_path("/foo").to_s
|
||||||
|
expect(args[args.length - 3]).to eql("#{expected}/")
|
||||||
|
end
|
||||||
|
|
||||||
|
subject.rsync_single(machine, ssh_info, opts)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "uses the custom arguments if given" do
|
||||||
|
opts[:args] = ["--verbose", "-z"]
|
||||||
|
|
||||||
|
Vagrant::Util::Subprocess.should_receive(:execute).with do |*args|
|
||||||
|
expect(args[1]).to eq("--verbose")
|
||||||
|
expect(args[2]).to eq("-z")
|
||||||
|
|
||||||
|
expected = Vagrant::Util::Platform.fs_real_path("/foo").to_s
|
||||||
|
expect(args[args.length - 3]).to eql("#{expected}/")
|
||||||
|
end
|
||||||
|
|
||||||
|
subject.rsync_single(machine, ssh_info, opts)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -39,6 +39,9 @@ it will tell you.
|
||||||
|
|
||||||
The rsync synced folder type accepts the following options:
|
The rsync synced folder type accepts the following options:
|
||||||
|
|
||||||
|
* `rsync__args` (string or array of strings) - A list of arguments to supply
|
||||||
|
to `rsync`. By default this is "--verbose --archive --delete -z".
|
||||||
|
|
||||||
* `rsync__exclude` (string or array of strings) - A list of files or directories
|
* `rsync__exclude` (string or array of strings) - A list of files or directories
|
||||||
to exclude from the sync. The values can be any acceptable rsync exclude
|
to exclude from the sync. The values can be any acceptable rsync exclude
|
||||||
pattern. By default, the ".vagrant/" directory is excluded. We recommend
|
pattern. By default, the ".vagrant/" directory is excluded. We recommend
|
||||||
|
|
Loading…
Reference in New Issue