Example #1
0
 protected function getClient($url)
 {
     $client = new Svn($url);
     $client->getAdapter()->setExecutable('svn');
     if (null !== $this->dispatcher) {
         $client->setDispatcher($this->dispatcher);
     }
     return $client;
 }
Example #2
0
 /**
  * Parse the Xml result from Subversion
  *
  * @param  string $output
  * @param  array  $arguments
  * @return array
  */
 protected function parseDiffOutput($output, array $arguments = array())
 {
     if (!isset($arguments['--xml']) || false === $arguments['--xml']) {
         // non xml results are not supported
         return $output;
     }
     if (!isset($arguments['--summarize']) || false === $arguments['--summarize']) {
         // non summarized results are not supported
         return $output;
     }
     $sxml = simplexml_load_string($output);
     $retval = array();
     foreach ($sxml->xpath('//path') as $item) {
         $url = (string) $item;
         $path = ltrim(str_replace($this->client->getSvnUrl(''), '', $url), '/');
         // @todo move to a Mapper class?
         $status = (string) $item->attributes()->item;
         switch ($status) {
             case "modified":
                 $status = Status::MODIFIED;
                 break;
             case "added":
                 $status = Status::ADDED;
                 break;
             case "deleted":
                 $status = Status::DELETED;
                 break;
         }
         $file = new VcsFileInfo($path, $this->getClient()->getHead());
         $file->setStatus($status);
         $retval[] = $file;
     }
     return $retval;
 }
Example #3
0
 /**
  * Get the status of the working copy
  *
  * @param  string                              $path
  * @return \Webcreate\Vcs\Common\VcsFileInfo[]
  */
 public function status($path = null)
 {
     $args = array();
     if (null !== $path) {
         $args[] = $path;
     }
     return $this->svn->execute('status', $args, $this->cwd);
 }
 public function setUp()
 {
     $this->tmpdir = sys_get_temp_dir() . '/' . uniqid('conveyor');
     $this->projectdir = $this->tmpdir . '/project';
     $this->reposdir = $this->tmpdir . '/repos';
     $this->reposurl = 'file:///' . $this->reposdir;
     $this->filesystem = new Filesystem();
     $this->filesystem->mkdir($this->tmpdir);
     $this->filesystem->mkdir($this->projectdir);
     $svnadminbin = getenv('SVNADMIN_BIN') ? getenv('SVNADMIN_BIN') : '/usr/local/bin/svnadmin';
     $svnbin = getenv('SVN_BIN') ? getenv('SVN_BIN') : '/usr/local/bin/svn';
     if (!file_exists($svnadminbin)) {
         $this->markTestSkipped(sprintf('%s not found', $svnadminbin));
     }
     if (!file_exists($svnbin)) {
         $this->markTestSkipped(sprintf('%s not found', $svnbin));
     }
     $svnadmin = new Svnadmin($this->tmpdir, $svnadminbin);
     $svnadmin->create(basename($this->reposdir));
     $svn = new Svn($this->reposurl, new CliAdapter($svnbin, new Cli(), new CliParser()));
     $svn->import(__DIR__ . '/../Test/Fixtures/skeleton/svn/trunk', '/', 'imported skeleton');
     $svn->setHead(new Reference('2.1', Reference::TAG));
     $svn->import(__DIR__ . '/../Test/Fixtures/skeleton/svn/tags/2.1', '/', 'imported skeleton');
     $svn->setHead(new Reference('feature1', Reference::BRANCH));
     $svn->import(__DIR__ . '/../Test/Fixtures/skeleton/svn/branches/feature1', '/', 'imported skeleton');
     $content = file_get_contents(__DIR__ . '/../Test/Fixtures/conveyor.yml.twig');
     $content = str_replace('{{ repository.url }}', $this->reposurl, $content);
     file_put_contents($this->projectdir . '/conveyor.yml', $content);
     chdir($this->projectdir);
 }