From afa7fb8d75a34efeb7a3de4b52139437e22fb31d Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Sun, 22 Jan 2012 20:08:45 +0100 Subject: [PATCH] Check for changes before updating/removing svn checkouts --- src/Composer/Downloader/SvnDownloader.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Composer/Downloader/SvnDownloader.php b/src/Composer/Downloader/SvnDownloader.php index 7661760bb..25ddca2cf 100644 --- a/src/Composer/Downloader/SvnDownloader.php +++ b/src/Composer/Downloader/SvnDownloader.php @@ -58,6 +58,7 @@ class SvnDownloader implements DownloaderInterface throw new \InvalidArgumentException('The given package is missing reference information'); } + $this->enforceCleanDirectory($path); $url = escapeshellarg($target->getSourceUrl()); $ref = escapeshellarg($target->getSourceReference()); $this->process->execute(sprintf('cd %s && svn switch %s/%s', $path, $url, $ref)); @@ -68,7 +69,16 @@ class SvnDownloader implements DownloaderInterface */ public function remove(PackageInterface $package, $path) { + $this->enforceCleanDirectory($path); $fs = new Util\Filesystem(); $fs->removeDirectory($path); } + + private function enforceCleanDirectory($path) + { + $this->process->execute(sprintf('cd %s && svn status', $path), $output); + if (trim($output)) { + throw new \RuntimeException('Source directory has uncommitted changes'); + } + } } \ No newline at end of file