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

Breadcrumb

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

function Perforce::getBranches

Return value

array{master: string}

File

vendor/composer/composer/src/Composer/Util/Perforce.php, line 500

Class

Perforce
@author Matt Whittom <Matt.Whittom@veteransunited.com>

Namespace

Composer\Util

Code

public function getBranches() : array {
    $possibleBranches = [];
    if (!$this->isStream()) {
        $possibleBranches[$this->p4Branch] = $this->getStream();
    }
    else {
        $command = $this->generateP4Command('streams ' . ProcessExecutor::escape('//' . $this->p4Depot . '/...'));
        $this->executeCommand($command);
        $result = $this->commandResult;
        $resArray = explode(PHP_EOL, $result);
        foreach ($resArray as $line) {
            $resBits = explode(' ', $line);
            if (count($resBits) > 4) {
                $branch = Preg::replace('/[^A-Za-z0-9 ]/', '', $resBits[4]);
                $possibleBranches[$branch] = $resBits[1];
            }
        }
    }
    $command = $this->generateP4Command('changes ' . ProcessExecutor::escape($this->getStream() . '/...'), false);
    $this->executeCommand($command);
    $result = $this->commandResult;
    $resArray = explode(PHP_EOL, $result);
    $lastCommit = $resArray[0];
    $lastCommitArr = explode(' ', $lastCommit);
    $lastCommitNum = $lastCommitArr[1];
    return [
        'master' => $possibleBranches[$this->p4Branch] . '@' . $lastCommitNum,
    ];
}

API Navigation

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