From 24eac88321df252c6b3fc6194e22f9c5ca9f64b6 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Mon, 20 Dec 2021 13:42:11 +0100 Subject: [PATCH] Switch the default version in path repo packages to dev-main and add a dev-master alias for BC, fixes #10360 (#10372) --- src/Composer/Repository/PathRepository.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Composer/Repository/PathRepository.php b/src/Composer/Repository/PathRepository.php index 887d8151e..3cb879c5c 100644 --- a/src/Composer/Repository/PathRepository.php +++ b/src/Composer/Repository/PathRepository.php @@ -15,6 +15,8 @@ namespace Composer\Repository; use Composer\Config; use Composer\IO\IOInterface; use Composer\Json\JsonFile; +use Composer\Package\CompleteAliasPackage; +use Composer\Package\CompletePackage; use Composer\Package\Loader\ArrayLoader; use Composer\Package\Version\VersionGuesser; use Composer\Package\Version\VersionParser; @@ -195,6 +197,7 @@ class PathRepository extends ArrayRepository implements ConfigurableRepositoryIn $package['dist']['reference'] = trim($output); } + $needsAlias = false; if (!isset($package['version'])) { $versionData = $this->versionGuesser->guessVersion($package, $path); if (is_array($versionData) && $versionData['pretty_version']) { @@ -206,11 +209,16 @@ class PathRepository extends ArrayRepository implements ConfigurableRepositoryIn $package['version'] = $versionData['pretty_version']; } else { - $package['version'] = 'dev-master'; + $package['version'] = 'dev-main'; + $needsAlias = true; } } $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); } }