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

Use vcs dir as git reference, if existing, to speed up download

Also added home dir to default initial settings
Luís Faceira пре 10 година
родитељ
комит
292bd3f6a3
2 измењених фајлова са 4 додато и 1 уклоњено
  1. 1 0
      src/Composer/Config.php
  2. 3 1
      src/Composer/Downloader/GitDownloader.php

+ 1 - 0
src/Composer/Config.php

@@ -59,6 +59,7 @@ class Config
         'platform' => array(),
         'platform' => array(),
         'archive-format' => 'tar',
         'archive-format' => 'tar',
         'archive-dir' => '.',
         'archive-dir' => '.',
+        'home' => '$HOME'
         // valid keys without defaults (auth config stuff):
         // valid keys without defaults (auth config stuff):
         // bitbucket-oauth
         // bitbucket-oauth
         // github-oauth
         // github-oauth

+ 3 - 1
src/Composer/Downloader/GitDownloader.php

@@ -42,10 +42,12 @@ class GitDownloader extends VcsDownloader implements DvcsDownloaderInterface
     {
     {
         GitUtil::cleanEnv();
         GitUtil::cleanEnv();
         $path = $this->normalizePath($path);
         $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();
         $ref = $package->getSourceReference();
         $flag = Platform::isWindows() ? '/D ' : '';
         $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);
         $this->io->writeError("    Cloning ".$ref);
 
 
         $commandCallable = function ($url) use ($ref, $path, $command) {
         $commandCallable = function ($url) use ($ref, $path, $command) {