From 292bd3f6a3860de38ed8bfcfda8e1c299db43627 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lu=C3=ADs=20Faceira?= Date: Wed, 9 Dec 2015 15:09:56 +0000 Subject: [PATCH] Use vcs dir as git reference, if existing, to speed up download Also added home dir to default initial settings --- src/Composer/Config.php | 1 + src/Composer/Downloader/GitDownloader.php | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Composer/Config.php b/src/Composer/Config.php index 59306f9d2..d8da9f215 100644 --- a/src/Composer/Config.php +++ b/src/Composer/Config.php @@ -59,6 +59,7 @@ class Config 'platform' => array(), 'archive-format' => 'tar', 'archive-dir' => '.', + 'home' => '$HOME' // valid keys without defaults (auth config stuff): // bitbucket-oauth // github-oauth diff --git a/src/Composer/Downloader/GitDownloader.php b/src/Composer/Downloader/GitDownloader.php index 94a8d78d9..c6767d2fe 100644 --- a/src/Composer/Downloader/GitDownloader.php +++ b/src/Composer/Downloader/GitDownloader.php @@ -42,10 +42,12 @@ 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) ? $cacheOptions = '--reference '.$cachePath.' ' : ''; $ref = $package->getSourceReference(); $flag = Platform::isWindows() ? '/D ' : ''; - $command = 'git clone --no-checkout %s %s && cd '.$flag.'%2$s && git remote add composer %1$s && git fetch composer'; + $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); $commandCallable = function ($url) use ($ref, $path, $command) {