1
0
Fork 0

* refactor SvnDownloader to use new Util Class

* now supports auth all over
 * svn command generation is proxied through one place
 * still needs the 'interactive' settings and an execute method
pull/410/head
till 2012-03-22 17:19:10 +01:00
parent 17f90f56eb
commit 3de8d66a82
1 changed files with 36 additions and 10 deletions

View File

@ -14,22 +14,32 @@ namespace Composer\Downloader;
use Composer\Package\PackageInterface;
use Composer\Util\ProcessExecutor;
use Composer\Util\Svn as SvnUtil;
/**
* @author Ben Bieker <mail@ben-bieker.de>
*/
class SvnDownloader extends VcsDownloader
{
/**
* @var \Composer\Util\Svn $util
*/
protected $util;
/**
* {@inheritDoc}
*/
public function doDownload(PackageInterface $package, $path)
{
$url = escapeshellarg($package->getSourceUrl());
$ref = escapeshellarg($package->getSourceReference());
$path = escapeshellarg($path);
$url = $package->getSourceUrl();
$ref = $package->getSourceReference();
$util = $this->getUtil($url);
$command = $util->getCommand("svn co", sprintf("%s/%s", $url, $ref), $path);
$this->io->write(" Checking out ".$package->getSourceReference());
$this->process->execute(sprintf('svn co %s/%s %s', $url, $ref, $path));
$this->process->execute($command);
}
/**
@ -37,11 +47,14 @@ class SvnDownloader extends VcsDownloader
*/
public function doUpdate(PackageInterface $initial, PackageInterface $target, $path)
{
$ref = escapeshellarg($target->getSourceReference());
$path = escapeshellarg($path);
$url = escapeshellarg($target->getSourceUrl());
$this->io->write(" Checking out ".$target->getSourceReference());
$this->process->execute(sprintf('cd %s && svn switch %s/%s', $path, $url, $ref));
$url = $target->getSourceUrl();
$ref = $target->getSourceReference();
$util = $this->getUtil($url);
$command = $util->getCommand("svn switch", sprintf("%s/%s", $url, $ref));
$this->io->write(" Checking out " . $ref);
$this->process->execute(sprintf('cd %s && %s', $path, $command));
}
/**
@ -54,4 +67,17 @@ class SvnDownloader extends VcsDownloader
throw new \RuntimeException('Source directory ' . $path . ' has uncommitted changes');
}
}
}
/**
* This is heavy - recreating Util often.
*
* @param string $url
*
* @return \Composer\Util\Svn
*/
protected function getUtil($url)
{
$util = new SvnUtil($url, $this->io);
return $util;
}
}