refactored "svn --version" calls into a single place, closes #7152
this saves a lot of process-spawning as we re-use the result of a process started once.pull/7096/merge
parent
2f56c3c334
commit
71d058b97b
|
@ -57,11 +57,10 @@ class SvnDownloader extends VcsDownloader
|
|||
throw new \RuntimeException('The .svn directory is missing from '.$path.', see https://getcomposer.org/commit-deps for more information');
|
||||
}
|
||||
|
||||
$util = new SvnUtil($url, $this->io, $this->config);
|
||||
$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';
|
||||
}
|
||||
if (version_compare($util->binaryVersion(), '1.7.0', '>=')) {
|
||||
$flags .= ' --ignore-ancestry';
|
||||
}
|
||||
|
||||
$this->io->writeError(" Checking out " . $ref);
|
||||
|
|
|
@ -353,7 +353,7 @@ class SvnDriver extends VcsDriver
|
|||
try {
|
||||
return $this->util->execute($command, $url);
|
||||
} catch (\RuntimeException $e) {
|
||||
if (0 !== $this->process->execute('svn --version', $ignoredOutput)) {
|
||||
if (null === $this->util->binaryVersion()) {
|
||||
throw new \RuntimeException('Failed to load '.$this->url.', svn was not found, check that it is installed and in your PATH env.' . "\n\n" . $this->process->getErrorOutput());
|
||||
}
|
||||
|
||||
|
|
|
@ -63,6 +63,11 @@ class Svn
|
|||
*/
|
||||
protected $config;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
static private $version;
|
||||
|
||||
/**
|
||||
* @param string $url
|
||||
* @param \Composer\IO\IOInterface $io
|
||||
|
@ -359,4 +364,22 @@ class Svn
|
|||
|
||||
return $this->hasAuth = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the version of the svn binary contained in PATH
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function binaryVersion()
|
||||
{
|
||||
if (!self::$version) {
|
||||
if (0 === $this->process->execute('svn --version', $output)) {
|
||||
if (preg_match('{(\d+(?:\.\d+)+)}', $output, $match)) {
|
||||
self::$version = $match[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return self::$version;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue