Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

added rsync extension #2

Merged
merged 1 commit into from

4 participants

@micheleorselli

estensione che aggiunge rsync per gestire i deploy delle app ez che abbiamo oggi in casa

@p16

+1

@fullo
Owner

maybe rename the extension from "Project" to "Rsync" ?

@micheleorselli

@fullo shamelessly copied from fabric https://github.com/fabric/fabric/blob/master/fabric/contrib/project.py
The idea is to add more strategies eg: deploy via tar + scp. Thus I would mantain the name "Project"

@kea kea merged commit abd6a25 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 23, 2013
  1. @micheleorselli

    added rsync extension

    micheleorselli authored
This page is out of date. Refresh to see the latest.
View
33 composer.lock
@@ -3,17 +3,17 @@
"packages": [
{
"name": "symfony/console",
- "version": "2.0.x-dev",
+ "version": "v2.0.23",
"target-dir": "Symfony/Component/Console",
"source": {
"type": "git",
- "url": "https://github.com/symfony/Console",
- "reference": "v2.0.13"
+ "url": "https://github.com/symfony/Console.git",
+ "reference": "v2.0.23"
},
"dist": {
"type": "zip",
- "url": "https://github.com/symfony/Console/zipball/v2.0.13",
- "reference": "v2.0.13",
+ "url": "https://api.github.com/repos/symfony/Console/zipball/v2.0.23",
+ "reference": "v2.0.23",
"shasum": ""
},
"require": {
@@ -25,26 +25,23 @@
"Symfony\\Component\\Console": ""
}
},
+ "notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
- "email": "fabien@symfony.com",
- "homepage": null,
- "role": null
+ "email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
- "email": null,
- "homepage": "http://symfony.com/contributors",
- "role": null
+ "homepage": "http://symfony.com/contributors"
}
],
"description": "Symfony Console Component",
"homepage": "http://symfony.com",
- "time": "2012-04-29 19:28:50"
+ "time": "2013-02-27 09:08:35"
},
{
"name": "symfony/process",
@@ -70,7 +67,7 @@
"Symfony\\Component\\Process": ""
}
},
- "notification-url": "http://packagist.org/downloads/",
+ "notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
@@ -89,12 +86,20 @@
"time": "2013-02-18 21:27:57"
}
],
- "packages-dev": null,
+ "packages-dev": [
+
+ ],
"aliases": [
],
"minimum-stability": "stable",
"stability-flags": [
+ ],
+ "platform": [
+
+ ],
+ "platform-dev": [
+
]
}
View
43 src/Idephix/Extension/Project/Project.php
@@ -0,0 +1,43 @@
+<?php
+
+namespace Idephix\Extension\Project;
+
+use Idephix\Idephix;
+use Idephix\Extension\IdephixAwareInterface;
+
+/**
+ * @todo:
+ * - allow for $exclude to be an array
+ * - manage ports different from the default one
+ * - check to undefined params in currentTarget
+ */
+class Project implements IdephixAwareInterface
+{
+ private $idx;
+
+ public function setIdephix(Idephix $idx)
+ {
+ $this->idx = $idx;
+ }
+
+ public function rsyncProject($remote_dir, $local_dir = null, $exclude = null, $extra_opts = null, $ssh_opts = null)
+ {
+ if (substr($remote_dir, -1) != '/')
+ {
+ $remote_dir .= '/';
+ }
+
+ $target = $this->idx->getCurrentTarget();
+ $user = $target['ssh_params']['user'];
+ $host = $this->idx->getCurrentTargetHost();
+
+ if (file_exists($exclude))
+ {
+ $extra_opts .= ' --exclude-from='.$exclude;
+ }
+
+ $cmd = "rsync -rlDcz --force --delete --progress $extra_opts -e 'ssh' ./ $user@$host:$remote_dir";
+
+ return $this->idx->local($cmd);
+ }
+}
View
38 tests/Idephix/Extension/Project/ProjectTest.php
@@ -0,0 +1,38 @@
+<?php
+namespace Idephix\Extension\Project;
+
+use Idephix\Extension\Project\Project;
+
+class ProjectTest extends \PHPUnit_Framework_TestCase
+{
+ public function setUp()
+ {
+ $this->idx = $this->getMockBuilder('Idephix\Idephix')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->idx->expects($this->exactly(1))
+ ->method('local')
+ ->will($this->returnArgument(0));
+
+ $this->idx->expects($this->exactly(1))
+ ->method('getCurrentTarget')
+ ->will($this->returnValue(array('ssh_params' => array('user' => 'kea'))));
+
+ $this->idx->expects($this->exactly(1))
+ ->method('getCurrentTargetHost')
+ ->will($this->returnValue('banana.com'));
+
+ $this->project = new Project();
+ $this->project->setIdephix($this->idx);
+
+ }
+
+ public function testRsyncProject()
+ {
+ $result = $this->project->rsyncProject('/a/remote');
+
+ $this->assertEquals("rsync -rlDcz --force --delete --progress -e 'ssh' ./ kea@banana.com:/a/remote/", $result);
+ }
+
+}
Something went wrong with that request. Please try again.