* 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
main
till 12 years ago
parent 17f90f56eb
commit 3de8d66a82

@ -14,22 +14,32 @@ namespace Composer\Downloader;
use Composer\Package\PackageInterface; use Composer\Package\PackageInterface;
use Composer\Util\ProcessExecutor; use Composer\Util\ProcessExecutor;
use Composer\Util\Svn as SvnUtil;
/** /**
* @author Ben Bieker <mail@ben-bieker.de> * @author Ben Bieker <mail@ben-bieker.de>
*/ */
class SvnDownloader extends VcsDownloader class SvnDownloader extends VcsDownloader
{ {
/**
* @var \Composer\Util\Svn $util
*/
protected $util;
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function doDownload(PackageInterface $package, $path) public function doDownload(PackageInterface $package, $path)
{ {
$url = escapeshellarg($package->getSourceUrl()); $url = $package->getSourceUrl();
$ref = escapeshellarg($package->getSourceReference()); $ref = $package->getSourceReference();
$path = escapeshellarg($path);
$util = $this->getUtil($url);
$command = $util->getCommand("svn co", sprintf("%s/%s", $url, $ref), $path);
$this->io->write(" Checking out ".$package->getSourceReference()); $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) public function doUpdate(PackageInterface $initial, PackageInterface $target, $path)
{ {
$ref = escapeshellarg($target->getSourceReference()); $url = $target->getSourceUrl();
$path = escapeshellarg($path); $ref = $target->getSourceReference();
$url = escapeshellarg($target->getSourceUrl());
$this->io->write(" Checking out ".$target->getSourceReference()); $util = $this->getUtil($url);
$this->process->execute(sprintf('cd %s && svn switch %s/%s', $path, $url, $ref)); $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'); 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;
}
}

Loading…
Cancel
Save