Permalink
Browse files

Merge pull request #288 from splinter89/fix-rsync-remote-detection

Detect rsync remote connection using colon
  • Loading branch information...
2 parents 7ab91f9 + a6c3476 commit 48178681fb590c17c0f1d5808ca64238f527cb17 @mrook mrook committed Jun 23, 2014
@@ -190,15 +190,15 @@ public function executeCommand()
throw new BuildException('The "destinationdir" attribute is missing or undefined.');
}
- if (strpos($this->destinationDir, '@')) {
+ if (strpos($this->destinationDir, ':')) {
$this->setIsRemoteConnection(true);
} else {
if (! (is_dir($this->destinationDir) && is_readable($this->destinationDir))) {
throw new BuildException("No such file or directory: " . $this->destinationDir);
}
}
- if (strpos($this->sourceDir, '@')) {
+ if (strpos($this->sourceDir, ':')) {
if ($this->isRemoteConnection) {
throw new BuildException('The source and destination cannot both be remote.');
}
@@ -482,7 +482,7 @@ public function setDryRun($dryRun)
/**
* Requests a simple itemized list of the changes that are being made to each file, including attribute changes.
*
- * @param boolean $dryRun
+ * @param boolean $itemizeChanges
* @return void
*/
public function setItemizeChanges($itemizeChanges)
@@ -536,4 +536,4 @@ public function setIdentityFile($identity)
{
$this->identityFile = $identity;
}
-}
+}
@@ -1004,16 +1004,19 @@
</tgroup>
</table>
<sect2>
- <title>Example</title>
- <programlisting language="xml">&lt;filesync sourcedir="/var/www/development/project1" destinationdir="/var/www/project1" />;
+ <title>Examples</title>
+ <programlisting language="xml">&lt;filesync sourcedir="/var/www/development/project1" destinationdir="/var/www/project1" />
+
+&lt;filesync sourcedir="host::module" destinationdir="/var/www/project1/" />
&lt;filesync
-sourcedir="/var/www/development/project1"
-destinationdir="user@server:/var/www/project1"
-dryrun="true"
-itemizechanges="true"
-verbose="true"
-checksum="true" />;</programlisting>
+ sourcedir="/var/www/development/project1"
+ destinationdir="user@server:/var/www/project1"
+ dryrun="true"
+ itemizechanges="true"
+ verbose="true"
+ checksum="true" /></programlisting>
+ <para>In the <literal>sourcedir</literal> and <literal>destinationdir</literal> properties user name for remote connections is optional.</para>
</sect2>
</sect1>
<sect1 role="taskdef" xml:id="FtpDeployTask">
@@ -0,0 +1,83 @@
+<?php
+/*
+ * $Id$
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * and is licensed under the LGPL. For more information please see
+ * <http://phing.info>.
+ */
+
+require_once 'phing/BuildFileTest.php';
+require_once '../classes/phing/tasks/ext/FileSyncTask.php';
+
+/**
+ * Tests the FileSync Task
+ *
+ * @author Anton <i.splinter@i.ua>
+ * @version $Id$
+ * @package phing.tasks.ext
+ */
+class FileSyncTaskTest extends BuildFileTest
+{
+ public function setUp()
+ {
+ $this->configureProject(PHING_TEST_BASE
+ . "/etc/tasks/ext/FileSyncTaskTest.xml");
+ $this->executeTarget("setup");
+ }
+
+ public function tearDown()
+ {
+ $this->executeTarget("clean");
+ }
+
+ public function testNoSourceSpecified()
+ {
+ $this->expectBuildExceptionContaining('noSourceDir',
+ 'No source set',
+ '"sourcedir" attribute is missing');
+ }
+
+ public function testNoDestinationSpecified()
+ {
+ $this->expectBuildExceptionContaining('noDestinationDir',
+ 'No destination set',
+ '"destinationdir" attribute is missing');
+ }
+
+ public function testNonexistentSource()
+ {
+ $this->expectBuildExceptionContaining('wrongSource',
+ 'Local source directory must be readable',
+ 'No such file or directory');
+ }
+
+// public function testLocalFileSync()
+// {
+// $this->executeTarget(__FUNCTION__);
+// }
+//
+// public function testRemoteFileSync()
+// {
+// $this->executeTarget(__FUNCTION__);
+// }
+
+ public function testRemoteToRemoteSync()
+ {
+ $this->expectBuildExceptionContaining(__FUNCTION__,
+ 'Either "sourcedir" or "destinationdir" must be local',
+ 'The source and destination cannot both be remote');
+ }
+}
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project name="FileSyncTaskTest" default="main">
+ <property name="tmp.dir" value="tmp"/>
+
+ <target name="setup">
+ <mkdir dir="${tmp.dir}/project"/>
+ </target>
+
+ <target name="clean">
+ <delete dir="${tmp.dir}"/>
+ </target>
+
+ <target name="noSourceDir">
+ <filesync destinationdir="${tmp.dir}/destination/"/>
+ </target>
+
+ <target name="noDestinationDir">
+ <filesync sourcedir="${tmp.dir}/project/"/>
+ </target>
+
+ <target name="wrongSource">
+ <filesync sourcedir="${tmp.dir}/nonexistent/" destinationdir="${tmp.dir}/destination/"/>
+ </target>
+
+ <!--target name="testLocalFileSync">
+ <filesync sourcedir="${tmp.dir}/project/" destinationdir="${tmp.dir}/destination/"/>
+ </target>
+
+ <target name="testRemoteFileSync">
+ <filesync sourcedir="${tmp.dir}/project" destinationdir="host:/var/www/project"/>
+ <filesync sourcedir="${tmp.dir}/project" destinationdir="user@host:/var/www/project"/>
+ <filesync sourcedir="${tmp.dir}/project" destinationdir="host::module"/>
+ <filesync sourcedir="host:/var/www/project" destinationdir="${tmp.dir}/project"/>
+ <filesync sourcedir="user@host:/var/www/remote_project/" destinationdir="${tmp.dir}/project/"/>
+ </target-->
+
+ <target name="testRemoteToRemoteSync">
+ <filesync sourcedir="host1::module" destinationdir="user@host2:/var/www/project"/>
+ </target>
+
+ <target name="main"/>
+</project>

0 comments on commit 4817868

Please sign in to comment.