1
0
Fork 0

Switch the default version in path repo packages to dev-main and add a dev-master alias for BC, fixes #10360 (#10372)

pull/10374/head
Jordi Boggiano 2021-12-20 13:42:11 +01:00 committed by GitHub
parent 95e41ae61c
commit 24eac88321
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 1 deletions

View File

@ -15,6 +15,8 @@ namespace Composer\Repository;
use Composer\Config; use Composer\Config;
use Composer\IO\IOInterface; use Composer\IO\IOInterface;
use Composer\Json\JsonFile; use Composer\Json\JsonFile;
use Composer\Package\CompleteAliasPackage;
use Composer\Package\CompletePackage;
use Composer\Package\Loader\ArrayLoader; use Composer\Package\Loader\ArrayLoader;
use Composer\Package\Version\VersionGuesser; use Composer\Package\Version\VersionGuesser;
use Composer\Package\Version\VersionParser; use Composer\Package\Version\VersionParser;
@ -195,6 +197,7 @@ class PathRepository extends ArrayRepository implements ConfigurableRepositoryIn
$package['dist']['reference'] = trim($output); $package['dist']['reference'] = trim($output);
} }
$needsAlias = false;
if (!isset($package['version'])) { if (!isset($package['version'])) {
$versionData = $this->versionGuesser->guessVersion($package, $path); $versionData = $this->versionGuesser->guessVersion($package, $path);
if (is_array($versionData) && $versionData['pretty_version']) { if (is_array($versionData) && $versionData['pretty_version']) {
@ -206,11 +209,16 @@ class PathRepository extends ArrayRepository implements ConfigurableRepositoryIn
$package['version'] = $versionData['pretty_version']; $package['version'] = $versionData['pretty_version'];
} else { } else {
$package['version'] = 'dev-master'; $package['version'] = 'dev-main';
$needsAlias = true;
} }
} }
$package = $this->loader->load($package); $package = $this->loader->load($package);
if ($needsAlias && $package instanceof CompletePackage) {
// keep a dev-master alias to dev-main for BC
$package = new CompleteAliasPackage($package, 'dev-master', 'dev-master');
}
$this->addPackage($package); $this->addPackage($package);
} }
} }