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

Breadcrumb

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

class FossilDownloader

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

Hierarchy

  • class \Composer\Downloader\VcsDownloader implements \Composer\Downloader\DownloaderInterface, \Composer\Downloader\ChangeReportInterface, \Composer\Downloader\VcsCapableDownloaderInterface
    • class \Composer\Downloader\FossilDownloader extends \Composer\Downloader\VcsDownloader

Expanded class hierarchy of FossilDownloader

File

vendor/composer/composer/src/Composer/Downloader/FossilDownloader.php, line 25

Namespace

Composer\Downloader
View source
class FossilDownloader extends VcsDownloader {
    
    /**
     * @inheritDoc
     */
    protected function doDownload(PackageInterface $package, string $path, string $url, ?PackageInterface $prevPackage = null) : PromiseInterface {
        return \React\Promise\resolve(null);
    }
    
    /**
     * @inheritDoc
     */
    protected function doInstall(PackageInterface $package, string $path, string $url) : PromiseInterface {
        // Ensure we are allowed to use this URL by config
        $this->config
            ->prohibitUrlByConfig($url, $this->io);
        $repoFile = $path . '.fossil';
        $realPath = Platform::realpath($path);
        $this->io
            ->writeError("Cloning " . $package->getSourceReference());
        $this->execute([
            'fossil',
            'clone',
            '--',
            $url,
            $repoFile,
        ]);
        $this->execute([
            'fossil',
            'open',
            '--nested',
            '--',
            $repoFile,
        ], $realPath);
        $this->execute([
            'fossil',
            'update',
            '--',
            (string) $package->getSourceReference(),
        ], $realPath);
        return \React\Promise\resolve(null);
    }
    
    /**
     * @inheritDoc
     */
    protected function doUpdate(PackageInterface $initial, PackageInterface $target, string $path, string $url) : PromiseInterface {
        // Ensure we are allowed to use this URL by config
        $this->config
            ->prohibitUrlByConfig($url, $this->io);
        $this->io
            ->writeError(" Updating to " . $target->getSourceReference());
        if (!$this->hasMetadataRepository($path)) {
            throw new \RuntimeException('The .fslckout file is missing from ' . $path . ', see https://getcomposer.org/commit-deps for more information');
        }
        $realPath = Platform::realpath($path);
        $this->execute([
            'fossil',
            'pull',
        ], $realPath);
        $this->execute([
            'fossil',
            'up',
            (string) $target->getSourceReference(),
        ], $realPath);
        return \React\Promise\resolve(null);
    }
    
    /**
     * @inheritDoc
     */
    public function getLocalChanges(PackageInterface $package, string $path) : ?string {
        if (!$this->hasMetadataRepository($path)) {
            return null;
        }
        $this->process
            ->execute([
            'fossil',
            'changes',
        ], $output, Platform::realpath($path));
        $output = trim($output);
        return strlen($output) > 0 ? $output : null;
    }
    
    /**
     * @inheritDoc
     */
    protected function getCommitLogs(string $fromReference, string $toReference, string $path) : string {
        $this->execute([
            'fossil',
            'timeline',
            '-t',
            'ci',
            '-W',
            '0',
            '-n',
            '0',
            'before',
            $toReference,
        ], Platform::realpath($path), $output);
        $log = '';
        $match = '/\\d\\d:\\d\\d:\\d\\d\\s+\\[' . $toReference . '\\]/';
        foreach ($this->process
            ->splitLines($output) as $line) {
            if (Preg::isMatch($match, $line)) {
                break;
            }
            $log .= $line;
        }
        return $log;
    }
    
    /**
     * @param non-empty-list<string> $command
     * @throws \RuntimeException
     */
    private function execute(array $command, ?string $cwd = null, ?string &$output = null) : void {
        if (0 !== $this->process
            ->execute($command, $output, $cwd)) {
            throw new \RuntimeException('Failed to execute ' . implode(' ', $command) . "\n\n" . $this->process
                ->getErrorOutput());
        }
    }
    
    /**
     * @inheritDoc
     */
    protected function hasMetadataRepository(string $path) : bool {
        return is_file($path . '/.fslckout') || is_file($path . '/_FOSSIL_');
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title Overrides
FossilDownloader::doDownload protected function @inheritDoc Overrides VcsDownloader::doDownload
FossilDownloader::doInstall protected function @inheritDoc Overrides VcsDownloader::doInstall
FossilDownloader::doUpdate protected function @inheritDoc Overrides VcsDownloader::doUpdate
FossilDownloader::execute private function
FossilDownloader::getCommitLogs protected function @inheritDoc Overrides VcsDownloader::getCommitLogs
FossilDownloader::getLocalChanges public function @inheritDoc Overrides ChangeReportInterface::getLocalChanges
FossilDownloader::hasMetadataRepository protected function @inheritDoc Overrides VcsDownloader::hasMetadataRepository
VcsDownloader::$config protected property @var Config
VcsDownloader::$filesystem protected property @var Filesystem
VcsDownloader::$hasCleanedChanges protected property @var array&lt;string, true&gt;
VcsDownloader::$io protected property @var IOInterface
VcsDownloader::$process protected property @var ProcessExecutor
VcsDownloader::cleanChanges protected function Prompt the user to check if changes should be stashed/removed or the operation aborted 2
VcsDownloader::cleanup public function @inheritDoc Overrides DownloaderInterface::cleanup
VcsDownloader::download public function @inheritDoc Overrides DownloaderInterface::download
VcsDownloader::getInstallationSource public function @inheritDoc Overrides DownloaderInterface::getInstallationSource
VcsDownloader::getVcsReference public function @inheritDoc Overrides VcsCapableDownloaderInterface::getVcsReference
VcsDownloader::install public function @inheritDoc Overrides DownloaderInterface::install
VcsDownloader::prepare public function @inheritDoc Overrides DownloaderInterface::prepare
VcsDownloader::prepareUrls private function
VcsDownloader::reapplyChanges protected function Reapply previously stashes changes if applicable, only called after an update (regardless if successful or not) 1
VcsDownloader::remove public function @inheritDoc Overrides DownloaderInterface::remove
VcsDownloader::update public function @inheritDoc Overrides DownloaderInterface::update
VcsDownloader::__construct public function 1

API Navigation

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