From 07b8fe81094cc022d54c528af73d8b84bea2194c Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Sat, 29 Mar 2014 14:16:13 +0100 Subject: [PATCH] Refactor code so it works cross-platform, refs #2825 --- src/Composer/Downloader/SvnDownloader.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Composer/Downloader/SvnDownloader.php b/src/Composer/Downloader/SvnDownloader.php index efb9faa25..8fefbdfc1 100644 --- a/src/Composer/Downloader/SvnDownloader.php +++ b/src/Composer/Downloader/SvnDownloader.php @@ -47,13 +47,15 @@ class SvnDownloader extends VcsDownloader throw new \RuntimeException('The .svn directory is missing from '.$path.', see http://getcomposer.org/commit-deps for more information'); } - $ignoreAncestryCommand = ""; - if ((int)$this->process->execute("svn --version | egrep 'version [0-9\.]+' -o | tr -d 'version .'") >= 170) { - $ignoreAncestryCommand = " --ignore-ancestry"; + $flags = ""; + if (0 === $this->process->execute('svn --version', $output)) { + if (preg_match('{(\d+(?:\.\d+)+)}', $output, $match) && version_compare($match[1], '1.7.0', '>=')) { + $flags .= ' --ignore-ancestry'; + } } $this->io->write(" Checking out " . $ref); - $this->execute($url, "svn switch" . $ignoreAncestry, sprintf("%s/%s", $url, $ref), $path); + $this->execute($url, "svn switch" . $flags, sprintf("%s/%s", $url, $ref), $path); } /**