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

Breadcrumb

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

function VcsDownloader::update

@inheritDoc

Overrides DownloaderInterface::update

File

vendor/composer/composer/src/Composer/Downloader/VcsDownloader.php, line 161

Class

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

Namespace

Composer\Downloader

Code

public function update(PackageInterface $initial, PackageInterface $target, string $path) : PromiseInterface {
    if (!$target->getSourceReference()) {
        throw new \InvalidArgumentException('Package ' . $target->getPrettyName() . ' is missing reference information');
    }
    $this->io
        ->writeError("  - " . UpdateOperation::format($initial, $target) . ': ', false);
    $urls = $this->prepareUrls($target->getSourceUrls());
    $exception = null;
    while ($url = array_shift($urls)) {
        try {
            $this->doUpdate($initial, $target, $path, $url);
            $exception = null;
            break;
        } catch (\Exception $exception) {
            // rethrow phpunit exceptions to avoid hard to debug bug failures
            if ($exception instanceof \PHPUnit\Framework\Exception) {
                throw $exception;
            }
            if ($this->io
                ->isDebug()) {
                $this->io
                    ->writeError('Failed: [' . get_class($exception) . '] ' . $exception->getMessage());
            }
            elseif (count($urls)) {
                $this->io
                    ->writeError('    Failed, trying the next URL');
            }
        }
    }
    // print the commit logs if in verbose mode and VCS metadata is present
    // because in case of missing metadata code would trigger another exception
    if (!$exception && $this->io
        ->isVerbose() && $this->hasMetadataRepository($path)) {
        $message = 'Pulling in changes:';
        $logs = $this->getCommitLogs($initial->getSourceReference(), $target->getSourceReference(), $path);
        if ('' === trim($logs)) {
            $message = 'Rolling back changes:';
            $logs = $this->getCommitLogs($target->getSourceReference(), $initial->getSourceReference(), $path);
        }
        if ('' !== trim($logs)) {
            $logs = implode("\n", array_map(static function ($line) : string {
                return '      ' . $line;
            }, explode("\n", $logs)));
            // escape angle brackets for proper output in the console
            $logs = str_replace('<', '\\<', $logs);
            $this->io
                ->writeError('    ' . $message);
            $this->io
                ->writeError($logs);
        }
    }
    if (!$urls && $exception) {
        throw $exception;
    }
    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