Преглед изворни кода

Refactor code so it works cross-platform, refs #2825

Jordi Boggiano пре 11 година
родитељ
комит
07b8fe8109
1 измењених фајлова са 6 додато и 4 уклоњено
  1. 6 4
      src/Composer/Downloader/SvnDownloader.php

+ 6 - 4
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);
     }
 
     /**