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

Breadcrumb

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

function GitHubDriver::getBranches

@inheritDoc

Overrides VcsDriverInterface::getBranches

1 call to GitHubDriver::getBranches()
GitHubDriver::getComposerInformation in vendor/composer/composer/src/Composer/Repository/Vcs/GitHubDriver.php
@inheritDoc

File

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

Class

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

Namespace

Composer\Repository\Vcs

Code

public function getBranches() : array {
    if ($this->gitDriver) {
        return $this->gitDriver
            ->getBranches();
    }
    if (null === $this->branches) {
        $branches = [];
        $resource = $this->getApiUrl() . '/repos/' . $this->owner . '/' . $this->repository . '/git/refs/heads?per_page=100';
        do {
            $response = $this->getContents($resource);
            $branchData = $response->decodeJson();
            foreach ($branchData as $branch) {
                $name = substr($branch['ref'], 11);
                if ($name !== 'gh-pages') {
                    $branches[$name] = $branch['object']['sha'];
                }
            }
            $resource = $this->getNextPage($response);
        } while ($resource);
        $this->branches = $branches;
    }
    return $this->branches;
}
RSS feed
Powered by Drupal