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

Breadcrumb

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

function GitDriver::getBranches

@inheritDoc

Overrides VcsDriverInterface::getBranches

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

File

vendor/composer/composer/src/Composer/Repository/Vcs/GitDriver.php, line 194

Class

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

Namespace

Composer\Repository\Vcs

Code

public function getBranches() : array {
    if (null === $this->branches) {
        $branches = [];
        $this->process
            ->execute([
            'git',
            'branch',
            '--no-color',
            '--no-abbrev',
            '-v',
        ], $output, $this->repoDir);
        foreach ($this->process
            ->splitLines($output) as $branch) {
            if ($branch !== '' && !Preg::isMatch('{^ *[^/]+/HEAD }', $branch)) {
                if (Preg::isMatchStrictGroups('{^(?:\\* )? *(\\S+) *([a-f0-9]+)(?: .*)?$}', $branch, $match) && $match[1][0] !== '-') {
                    $branches[$match[1]] = $match[2];
                }
            }
        }
        $this->branches = $branches;
    }
    return $this->branches;
}
RSS feed
Powered by Drupal