|
@@ -43,10 +43,21 @@ class GitDownloader extends VcsDownloader implements DvcsDownloaderInterface
|
|
|
GitUtil::cleanEnv();
|
|
|
$path = $this->normalizePath($path);
|
|
|
$cachePath = $this->config->get('cache-vcs-dir').'/'.preg_replace('{[^a-z0-9.]}i', '-', $url).'/';
|
|
|
- $cacheOptions = file_exists($cachePath) ? '--dissociate --reference '.ProcessExecutor::escape($cachePath).' ' : '';
|
|
|
-
|
|
|
$ref = $package->getSourceReference();
|
|
|
$flag = Platform::isWindows() ? '/D ' : '';
|
|
|
+
|
|
|
+ // --dissociate option is only available since git 2.3.0-rc0
|
|
|
+ if (version_compare($this->gitUtil->getVersion(), '2.3.0-rc0', '>=')) {
|
|
|
+ if (!file_exists($cachePath)) {
|
|
|
+ $this->io->writeError(sprintf(' Cloning to cache at %s', ProcessExecutor::escape($cachePath)));
|
|
|
+ $mirrorCommand = 'git clone --mirror %s %s';
|
|
|
+ $mirrorCommandCallable = function ($url) use ($cachePath, $mirrorCommand) {
|
|
|
+ return sprintf($mirrorCommand, ProcessExecutor::escape($url), ProcessExecutor::escape($cachePath));
|
|
|
+ };
|
|
|
+ $this->gitUtil->runCommand($mirrorCommandCallable, $url, $path, true);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $cacheOptions = file_exists($cachePath) ? '--dissociate --reference '.ProcessExecutor::escape($cachePath).' ' : '';
|
|
|
$command = 'git clone --no-checkout %s %s '.$cacheOptions.'&& cd '.$flag.'%2$s && git remote add composer %1$s && git fetch composer';
|
|
|
$this->io->writeError(" Cloning ".$ref);
|
|
|
|