Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. GitDownloader.php

function GitDownloader::doDownload

@inheritDoc

Overrides VcsDownloader::doDownload

File

vendor/composer/composer/src/Composer/Downloader/GitDownloader.php, line 61

Class

GitDownloader
@author Jordi Boggiano <j.boggiano@seld.be>

Namespace

Composer\Downloader

Code

protected function doDownload(PackageInterface $package, string $path, string $url, ?PackageInterface $prevPackage = null) : PromiseInterface {
    // Do not create an extra local cache when repository is already local
    if (Filesystem::isLocalPath($url)) {
        return \React\Promise\resolve(null);
    }
    GitUtil::cleanEnv();
    $cachePath = $this->config
        ->get('cache-vcs-dir') . '/' . Preg::replace('{[^a-z0-9.]}i', '-', Url::sanitize($url)) . '/';
    $gitVersion = GitUtil::getVersion($this->process);
    // --dissociate option is only available since git 2.3.0-rc0
    if ($gitVersion && version_compare($gitVersion, '2.3.0-rc0', '>=') && Cache::isUsable($cachePath)) {
        $this->io
            ->writeError("  - Syncing <info>" . $package->getName() . "</info> (<comment>" . $package->getFullPrettyVersion() . "</comment>) into cache");
        $this->io
            ->writeError(sprintf('    Cloning to cache at %s', $cachePath), true, IOInterface::DEBUG);
        $ref = $package->getSourceReference();
        if ($this->gitUtil
            ->fetchRefOrSyncMirror($url, $cachePath, $ref, $package->getPrettyVersion()) && is_dir($cachePath)) {
            $this->cachedPackages[$package->getId()][$ref] = true;
        }
    }
    elseif (null === $gitVersion) {
        throw new \RuntimeException('git was not found in your PATH, skipping source download');
    }
    return \React\Promise\resolve(null);
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal