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

Breadcrumb

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

function VersionGuesser::guessSvnVersion

Parameters

array<string, mixed> $packageConfig:

Return value

array{version: string, commit: '', pretty_version: string}|null

1 call to VersionGuesser::guessSvnVersion()
VersionGuesser::guessVersion in vendor/composer/composer/src/Composer/Package/Version/VersionGuesser.php
@phpstan-return Version|null

File

vendor/composer/composer/src/Composer/Package/Version/VersionGuesser.php, line 401

Class

VersionGuesser
Try to guess the current version number based on different VCS configuration.

Namespace

Composer\Package\Version

Code

private function guessSvnVersion(array $packageConfig, string $path) : ?array {
    SvnUtil::cleanEnv();
    // try to fetch current version from svn
    if (0 === $this->process
        ->execute([
        'svn',
        'info',
        '--xml',
    ], $output, $path)) {
        $trunkPath = isset($packageConfig['trunk-path']) ? preg_quote($packageConfig['trunk-path'], '#') : 'trunk';
        $branchesPath = isset($packageConfig['branches-path']) ? preg_quote($packageConfig['branches-path'], '#') : 'branches';
        $tagsPath = isset($packageConfig['tags-path']) ? preg_quote($packageConfig['tags-path'], '#') : 'tags';
        $urlPattern = '#<url>.*/(' . $trunkPath . '|(' . $branchesPath . '|' . $tagsPath . ')/(.*))</url>#';
        if (Preg::isMatch($urlPattern, $output, $matches)) {
            if (isset($matches[2], $matches[3]) && ($branchesPath === $matches[2] || $tagsPath === $matches[2])) {
                // we are in a branches path
                $version = $this->versionParser
                    ->normalizeBranch($matches[3]);
                $prettyVersion = 'dev-' . $matches[3];
                return [
                    'version' => $version,
                    'commit' => '',
                    'pretty_version' => $prettyVersion,
                ];
            }
            assert(is_string($matches[1]));
            $prettyVersion = trim($matches[1]);
            if ($prettyVersion === 'trunk') {
                $version = 'dev-trunk';
            }
            else {
                $version = $this->versionParser
                    ->normalize($prettyVersion);
            }
            return [
                'version' => $version,
                'commit' => '',
                'pretty_version' => $prettyVersion,
            ];
        }
    }
    return null;
}
RSS feed
Powered by Drupal