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

Breadcrumb

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

function GitHubDriver::fetchRootIdentifier

Fetch root identifier from GitHub

Throws

TransportException

2 calls to GitHubDriver::fetchRootIdentifier()
GitHubDriver::getRepoData in vendor/composer/composer/src/Composer/Repository/Vcs/GitHubDriver.php
Gives back the loaded <github-api>/repos/<owner>/<repo> result
GitHubDriver::initialize in vendor/composer/composer/src/Composer/Repository/Vcs/GitHubDriver.php
@inheritDoc

File

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

Class

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

Namespace

Composer\Repository\Vcs

Code

protected function fetchRootIdentifier() : void {
    if ($this->repoData) {
        return;
    }
    $repoDataUrl = $this->getApiUrl() . '/repos/' . $this->owner . '/' . $this->repository;
    try {
        $this->repoData = $this->getContents($repoDataUrl, true)
            ->decodeJson();
    } catch (TransportException $e) {
        if ($e->getCode() === 499) {
            $this->attemptCloneFallback();
        }
        else {
            throw $e;
        }
    }
    if (null === $this->repoData && null !== $this->gitDriver) {
        return;
    }
    $this->owner = $this->repoData['owner']['login'];
    $this->repository = $this->repoData['name'];
    $this->isPrivate = !empty($this->repoData['private']);
    if (isset($this->repoData['default_branch'])) {
        $this->rootIdentifier = $this->repoData['default_branch'];
    }
    elseif (isset($this->repoData['master_branch'])) {
        $this->rootIdentifier = $this->repoData['master_branch'];
    }
    else {
        $this->rootIdentifier = 'master';
    }
    $this->hasIssues = !empty($this->repoData['has_issues']);
    $this->isArchived = !empty($this->repoData['archived']);
}
RSS feed
Powered by Drupal