Rename DEV_MASTER_ALIAS to DEFAULT_BRANCH_ALIAS

main
Jordi Boggiano 4 years ago
parent 821e575658
commit 05dacbdabb
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC

@ -388,8 +388,8 @@ EOT
}
}
// avoid displaying 9999999-dev as version if dev-master was selected
if ($package instanceof AliasPackage && $package->getPrettyVersion() === VersionParser::DEV_MASTER_ALIAS) {
// avoid displaying 9999999-dev as version if default-branch was selected
if ($package instanceof AliasPackage && $package->getPrettyVersion() === VersionParser::DEFAULT_BRANCH_ALIAS) {
$package = $package->getAliasOf();
}

@ -329,14 +329,18 @@ class Problem
public static function getPackageList(array $packages, $isVerbose)
{
$prepared = array();
$hasDefaultBranch = array();
foreach ($packages as $package) {
$prepared[$package->getName()]['name'] = $package->getPrettyName();
$prepared[$package->getName()]['versions'][$package->getVersion()] = $package->getPrettyVersion().($package instanceof AliasPackage ? ' (alias of '.$package->getAliasOf()->getPrettyVersion().')' : '');
if ($package->isDefaultBranch()) {
$hasDefaultBranch[$package->getName()] = true;
}
}
foreach ($prepared as $name => $package) {
// remove the implicit dev-master alias to avoid cruft in the display
if (isset($package['versions'][VersionParser::DEV_MASTER_ALIAS]) && isset($package['versions']['dev-master'])) {
unset($package['versions'][VersionParser::DEV_MASTER_ALIAS]);
// remove the implicit default branch alias to avoid cruft in the display
if (isset($package['versions'][VersionParser::DEFAULT_BRANCH_ALIAS]) && isset($hasDefaultBranch[$name])) {
unset($package['versions'][VersionParser::DEFAULT_BRANCH_ALIAS]);
}
uksort($package['versions'], 'version_compare');

@ -183,7 +183,7 @@ abstract class Rule
return 'Root composer.json requires '.$packageName.($constraint ? ' '.$constraint->getPrettyString() : '').' -> satisfiable by '.$this->formatPackagesUnique($pool, $packages, $isVerbose).'.';
case self::RULE_FIXED:
$package = $this->deduplicateMasterAlias($this->reasonData['package']);
$package = $this->deduplicateDefaultBranchAlias($this->reasonData['package']);
if ($this->reasonData['lockable']) {
return $package->getPrettyName().' is locked to version '.$package->getPrettyVersion().' and an update of this package was not requested.';
}
@ -191,14 +191,14 @@ abstract class Rule
return $package->getPrettyName().' is present at version '.$package->getPrettyVersion() . ' and cannot be modified by Composer';
case self::RULE_PACKAGE_CONFLICT:
$package1 = $this->deduplicateMasterAlias($pool->literalToPackage($literals[0]));
$package2 = $this->deduplicateMasterAlias($pool->literalToPackage($literals[1]));
$package1 = $this->deduplicateDefaultBranchAlias($pool->literalToPackage($literals[0]));
$package2 = $this->deduplicateDefaultBranchAlias($pool->literalToPackage($literals[1]));
return $package2->getPrettyString().' conflicts with '.$package1->getPrettyString().'.';
case self::RULE_PACKAGE_REQUIRES:
$sourceLiteral = array_shift($literals);
$sourcePackage = $this->deduplicateMasterAlias($pool->literalToPackage($sourceLiteral));
$sourcePackage = $this->deduplicateDefaultBranchAlias($pool->literalToPackage($sourceLiteral));
$requires = array();
foreach ($literals as $literal) {
@ -281,7 +281,7 @@ abstract class Rule
$group = $literal > 0 ? 'install' : 'don\'t install';
}
$groups[$group][] = $this->deduplicateMasterAlias($package);
$groups[$group][] = $this->deduplicateDefaultBranchAlias($package);
}
$ruleTexts = array();
foreach ($groups as $group => $packages) {
@ -295,10 +295,10 @@ abstract class Rule
case self::RULE_PACKAGE_ALIAS:
$aliasPackage = $pool->literalToPackage($literals[0]);
// avoid returning content like "9999999-dev is an alias of dev-master" as it is useless
if ($aliasPackage->getVersion() === VersionParser::DEV_MASTER_ALIAS) {
if ($aliasPackage->getVersion() === VersionParser::DEFAULT_BRANCH_ALIAS) {
return '';
}
$package = $this->deduplicateMasterAlias($pool->literalToPackage($literals[1]));
$package = $this->deduplicateDefaultBranchAlias($pool->literalToPackage($literals[1]));
return $aliasPackage->getPrettyString() .' is an alias of '.$package->getPrettyString().' and thus requires it to be installed too.';
default:
@ -342,9 +342,9 @@ abstract class Rule
return $names;
}
private function deduplicateMasterAlias(PackageInterface $package)
private function deduplicateDefaultBranchAlias(PackageInterface $package)
{
if ($package instanceof AliasPackage && $package->getPrettyVersion() === VersionParser::DEV_MASTER_ALIAS) {
if ($package instanceof AliasPackage && $package->getPrettyVersion() === VersionParser::DEFAULT_BRANCH_ALIAS) {
$package = $package->getAliasOf();
}

@ -176,7 +176,7 @@ class AliasPackage extends BasePackage implements CompletePackageInterface
{
// for self.version requirements, we use the original package's branch name instead, to avoid leaking the magic dev-master-alias to users
$prettyVersion = $this->prettyVersion;
if ($prettyVersion === VersionParser::DEV_MASTER_ALIAS) {
if ($prettyVersion === VersionParser::DEFAULT_BRANCH_ALIAS) {
$prettyVersion = $this->aliasOf->getPrettyVersion();
}

@ -90,8 +90,8 @@ class ArrayLoader implements LoaderInterface
if (isset($config['version_normalized'])) {
$version = $config['version_normalized'];
// handling of existing repos which need to remain composer v1 compatible, in case the version_normalized contained VersionParser::DEV_MASTER_ALIAS, we renormalize it
if ($version === VersionParser::DEV_MASTER_ALIAS) {
// handling of existing repos which need to remain composer v1 compatible, in case the version_normalized contained VersionParser::DEFAULT_BRANCH_ALIAS, we renormalize it
if ($version === VersionParser::DEFAULT_BRANCH_ALIAS) {
$version = $this->versionParser->normalize($config['version']);
}
} else {
@ -369,7 +369,7 @@ class ArrayLoader implements LoaderInterface
}
if (isset($config['default-branch']) && $config['default-branch'] === true) {
return VersionParser::DEV_MASTER_ALIAS;
return VersionParser::DEFAULT_BRANCH_ALIAS;
}
}
}

@ -210,7 +210,7 @@ class VersionGuesser
$version = $this->versionParser->normalizeBranch($branch);
$isFeatureBranch = 0 === strpos($version, 'dev-');
if (VersionParser::DEV_MASTER_ALIAS === $version) {
if (VersionParser::DEFAULT_BRANCH_ALIAS === $version) {
return array('version' => $version, 'commit' => null, 'pretty_version' => 'dev-'.$branch);
}

@ -18,8 +18,8 @@ use Composer\Semver\Semver;
class VersionParser extends SemverVersionParser
{
const DEV_MASTER_ALIAS = '9999999-dev';
const DEFAULT_BRANCH_ALIAS = '9999999-dev';
private static $constraints = array();
/**
@ -72,8 +72,12 @@ class VersionParser extends SemverVersionParser
*/
public static function isUpgrade($normalizedFrom, $normalizedTo)
{
$normalizedFrom = str_replace(array('dev-master', 'dev-trunk', 'dev-default'), VersionParser::DEV_MASTER_ALIAS, $normalizedFrom);
$normalizedTo = str_replace(array('dev-master', 'dev-trunk', 'dev-default'), VersionParser::DEV_MASTER_ALIAS, $normalizedTo);
if ($normalizedFrom === $normalizedTo) {
return true;
}
$normalizedFrom = str_replace(array('dev-master', 'dev-trunk', 'dev-default'), VersionParser::DEFAULT_BRANCH_ALIAS, $normalizedFrom);
$normalizedTo = str_replace(array('dev-master', 'dev-trunk', 'dev-default'), VersionParser::DEFAULT_BRANCH_ALIAS, $normalizedTo);
if (substr($normalizedFrom, 0, 4) === 'dev-' || substr($normalizedTo, 0, 4) === 'dev-') {
return true;

@ -596,8 +596,8 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
if (!isset($versionsToLoad[$version['uid']])) {
if (!isset($version['version_normalized'])) {
$version['version_normalized'] = $this->versionParser->normalize($version['version']);
} elseif ($version['version_normalized'] === VersionParser::DEV_MASTER_ALIAS) {
// handling of existing repos which need to remain composer v1 compatible, in case the version_normalized contained VersionParser::DEV_MASTER_ALIAS, we renormalize it
} elseif ($version['version_normalized'] === VersionParser::DEFAULT_BRANCH_ALIAS) {
// handling of existing repos which need to remain composer v1 compatible, in case the version_normalized contained VersionParser::DEFAULT_BRANCH_ALIAS, we renormalize it
$version['version_normalized'] = $this->versionParser->normalize($version['version']);
}
@ -717,8 +717,8 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
foreach ($versions as $version) {
if (!isset($version['version_normalized'])) {
$version['version_normalized'] = $repo->versionParser->normalize($version['version']);
} elseif ($version['version_normalized'] === VersionParser::DEV_MASTER_ALIAS) {
// handling of existing repos which need to remain composer v1 compatible, in case the version_normalized contained VersionParser::DEV_MASTER_ALIAS, we renormalize it
} elseif ($version['version_normalized'] === VersionParser::DEFAULT_BRANCH_ALIAS) {
// handling of existing repos which need to remain composer v1 compatible, in case the version_normalized contained VersionParser::DEFAULT_BRANCH_ALIAS, we renormalize it
$version['version_normalized'] = $repo->versionParser->normalize($version['version']);
}

@ -306,7 +306,7 @@ class VcsRepository extends ArrayRepository implements ConfigurableRepositoryInt
}
// make sure branch packages have a dev flag
if ('dev-' === substr($parsedBranch, 0, 4) || VersionParser::DEV_MASTER_ALIAS === $parsedBranch) {
if ('dev-' === substr($parsedBranch, 0, 4) || VersionParser::DEFAULT_BRANCH_ALIAS === $parsedBranch) {
$version = 'dev-' . $branch;
} else {
$prefix = substr($branch, 0, 1) === 'v' ? 'v' : '';

@ -3,10 +3,10 @@ Update mirrors updates URLs for all packages if they have changed without updati
a/a is dev and gets everything updated as it updates to a new ref
b/b is a tag and gets everything updated by updating the package URL directly
c/c is a tag and not whitelisted and gets the new URL but keeps its old ref
c/c is a tag and not allowlisted for update and gets the new URL but keeps its old ref
d/d is dev but with a #ref so it should get URL updated but not the reference
e/e is dev and newly installed with a #ref so it should get the correct URL but with the #111 ref
e/e is dev but not whitelisted and gets the new URL but keeps its old ref
e/e is dev but not allowlisted for update and gets the new URL but keeps its old ref
g/g is dev and installed in a different ref than the #ref, so it gets updated and gets the new URL but not the new ref
--COMPOSER--
{

@ -49,9 +49,9 @@ class VersionParserTest extends TestCase
return array(
array('0.9.0.0', '1.0.0.0', true),
array('1.0.0.0', '0.9.0.0', false),
array('1.0.0.0', VersionParser::DEV_MASTER_ALIAS, true),
array(VersionParser::DEV_MASTER_ALIAS, VersionParser::DEV_MASTER_ALIAS, true),
array(VersionParser::DEV_MASTER_ALIAS, '1.0.0.0', false),
array('1.0.0.0', VersionParser::DEFAULT_BRANCH_ALIAS, true),
array(VersionParser::DEFAULT_BRANCH_ALIAS, VersionParser::DEFAULT_BRANCH_ALIAS, true),
array(VersionParser::DEFAULT_BRANCH_ALIAS, '1.0.0.0', false),
array('1.0.0.0', 'dev-foo', true),
array('dev-foo', 'dev-foo', true),
array('dev-foo', '1.0.0.0', true),

Loading…
Cancel
Save