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

Breadcrumb

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

function GitHubDriver::initialize

@inheritDoc

Overrides VcsDriverInterface::initialize

File

vendor/composer/composer/src/Composer/Repository/Vcs/GitHubDriver.php, line 60

Class

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

Namespace

Composer\Repository\Vcs

Code

public function initialize() : void {
    if (!Preg::isMatch('#^(?:(?:https?|git)://([^/]+)/|git@([^:]+):/?)([^/]+)/([^/]+?)(?:\\.git|/)?$#', $this->url, $match)) {
        throw new \InvalidArgumentException(sprintf('The GitHub repository URL %s is invalid.', $this->url));
    }
    $this->owner = $match[3];
    $this->repository = $match[4];
    $this->originUrl = strtolower($match[1] ?? (string) $match[2]);
    if ($this->originUrl === 'www.github.com') {
        $this->originUrl = 'github.com';
    }
    $this->cache = new Cache($this->io, $this->config
        ->get('cache-repo-dir') . '/' . $this->originUrl . '/' . $this->owner . '/' . $this->repository);
    $this->cache
        ->setReadOnly($this->config
        ->get('cache-read-only'));
    if ($this->config
        ->get('use-github-api') === false || isset($this->repoConfig['no-api']) && $this->repoConfig['no-api']) {
        $this->setupGitDriver($this->url);
        return;
    }
    $this->fetchRootIdentifier();
}
RSS feed
Powered by Drupal