|
@@ -18,65 +18,38 @@ use Composer\Util\ProcessExecutor;
|
|
/**
|
|
/**
|
|
* @author Ben Bieker <mail@ben-bieker.de>
|
|
* @author Ben Bieker <mail@ben-bieker.de>
|
|
*/
|
|
*/
|
|
-class SvnDownloader implements DownloaderInterface
|
|
|
|
|
|
+class SvnDownloader extends VcsDownloader
|
|
{
|
|
{
|
|
- protected $process;
|
|
|
|
-
|
|
|
|
- public function __construct(ProcessExecutor $process = null)
|
|
|
|
- {
|
|
|
|
- $this->process = $process ?: new ProcessExecutor;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * {@inheritDoc}
|
|
|
|
- */
|
|
|
|
- public function getInstallationSource()
|
|
|
|
- {
|
|
|
|
- return 'source';
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* {@inheritDoc}
|
|
* {@inheritDoc}
|
|
*/
|
|
*/
|
|
- public function download(PackageInterface $package, $path)
|
|
|
|
|
|
+ public function doDownload(PackageInterface $package, $path)
|
|
{
|
|
{
|
|
- if(!$package->getSourceReference()) {
|
|
|
|
- throw new \InvalidArgumentException('The given package is missing reference information');
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
$url = escapeshellarg($package->getSourceUrl());
|
|
$url = escapeshellarg($package->getSourceUrl());
|
|
$ref = escapeshellarg($package->getSourceReference());
|
|
$ref = escapeshellarg($package->getSourceReference());
|
|
|
|
+ $path = escapeshellarg($path);
|
|
|
|
+ $this->io->write(" Checking out ".$package->getSourceReference());
|
|
$this->process->execute(sprintf('svn co %s/%s %s', $url, $ref, $path));
|
|
$this->process->execute(sprintf('svn co %s/%s %s', $url, $ref, $path));
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* {@inheritDoc}
|
|
* {@inheritDoc}
|
|
*/
|
|
*/
|
|
- public function update(PackageInterface $initial, PackageInterface $target, $path)
|
|
|
|
|
|
+ public function doUpdate(PackageInterface $initial, PackageInterface $target, $path)
|
|
{
|
|
{
|
|
- if(!$target->getSourceReference()) {
|
|
|
|
- throw new \InvalidArgumentException('The given package is missing reference information');
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- $this->enforceCleanDirectory($path);
|
|
|
|
- $url = escapeshellarg($target->getSourceUrl());
|
|
|
|
$ref = escapeshellarg($target->getSourceReference());
|
|
$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));
|
|
$this->process->execute(sprintf('cd %s && svn switch %s/%s', $path, $url, $ref));
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* {@inheritDoc}
|
|
* {@inheritDoc}
|
|
*/
|
|
*/
|
|
- public function remove(PackageInterface $package, $path)
|
|
|
|
- {
|
|
|
|
- $this->enforceCleanDirectory($path);
|
|
|
|
- $fs = new Util\Filesystem();
|
|
|
|
- $fs->removeDirectory($path);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- private function enforceCleanDirectory($path)
|
|
|
|
|
|
+ protected function enforceCleanDirectory($path)
|
|
{
|
|
{
|
|
- $this->process->execute(sprintf('cd %s && svn status', $path), $output);
|
|
|
|
|
|
+ $this->process->execute(sprintf('cd %s && svn status', escapeshellarg($path)), $output);
|
|
if (trim($output)) {
|
|
if (trim($output)) {
|
|
throw new \RuntimeException('Source directory has uncommitted changes');
|
|
throw new \RuntimeException('Source directory has uncommitted changes');
|
|
}
|
|
}
|