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

Breadcrumb

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

function FossilDriver::updateLocalRepo

Clone or update existing local fossil repository.

1 call to FossilDriver::updateLocalRepo()
FossilDriver::initialize in vendor/composer/composer/src/Composer/Repository/Vcs/FossilDriver.php
@inheritDoc

File

vendor/composer/composer/src/Composer/Repository/Vcs/FossilDriver.php, line 82

Class

FossilDriver
@author BohwaZ <http://bohwaz.net/&gt;

Namespace

Composer\Repository\Vcs

Code

protected function updateLocalRepo() : void {
    assert($this->repoFile !== null);
    $fs = new Filesystem();
    $fs->ensureDirectoryExists($this->checkoutDir);
    if (!is_writable(dirname($this->checkoutDir))) {
        throw new \RuntimeException('Can not clone ' . $this->url . ' to access package information. The "' . $this->checkoutDir . '" directory is not writable by the current user.');
    }
    // update the repo if it is a valid fossil repository
    if (is_file($this->repoFile) && is_dir($this->checkoutDir) && 0 === $this->process
        ->execute([
        'fossil',
        'info',
    ], $output, $this->checkoutDir)) {
        if (0 !== $this->process
            ->execute([
            'fossil',
            'pull',
        ], $output, $this->checkoutDir)) {
            $this->io
                ->writeError('<error>Failed to update ' . $this->url . ', package information from this repository may be outdated (' . $this->process
                ->getErrorOutput() . ')</error>');
        }
    }
    else {
        // clean up directory and do a fresh clone into it
        $fs->removeDirectory($this->checkoutDir);
        $fs->remove($this->repoFile);
        $fs->ensureDirectoryExists($this->checkoutDir);
        if (0 !== $this->process
            ->execute([
            'fossil',
            'clone',
            '--',
            $this->url,
            $this->repoFile,
        ], $output)) {
            $output = $this->process
                ->getErrorOutput();
            throw new \RuntimeException('Failed to clone ' . $this->url . ' to repository ' . $this->repoFile . "\n\n" . $output);
        }
        if (0 !== $this->process
            ->execute([
            'fossil',
            'open',
            '--nested',
            '--',
            $this->repoFile,
        ], $output, $this->checkoutDir)) {
            $output = $this->process
                ->getErrorOutput();
            throw new \RuntimeException('Failed to open repository ' . $this->repoFile . ' in ' . $this->checkoutDir . "\n\n" . $output);
        }
    }
}
RSS feed
Powered by Drupal