1
0
Fork 0

Fix default-branch attribute on package files, and add it to schema

pull/8997/head
Jordi Boggiano 2020-06-19 15:08:01 +02:00
parent 6f0e5996de
commit 923f198a1f
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC
4 changed files with 13 additions and 9 deletions

View File

@ -565,6 +565,10 @@
"type": "string"
}
},
"default-branch": {
"type": ["boolean"],
"description": "Internal use only, do not specify this in composer.json. Indicates whether this version is the default branch of the linked VCS repository. Defaults to false."
},
"abandoned": {
"type": ["boolean", "string"],
"description": "Indicates whether this package has been abandoned, it can be boolean or a package name/URL pointing to a recommended alternative. Defaults to false."

View File

@ -96,7 +96,7 @@ class ArrayDumper
}
if ($package->isDefaultBranch()) {
$data['default_branch'] = true;
$data['default-branch'] = true;
}
$data = $this->dumpValues($package, $keys, $data);

View File

@ -124,7 +124,7 @@ class ArrayLoader implements LoaderInterface
$package->setInstallationSource($config['installation-source']);
}
if (isset($config['default_branch']) && $config['default_branch'] === true) {
if (isset($config['default-branch']) && $config['default-branch'] === true) {
$package->setIsDefaultBranch(true);
}
@ -368,7 +368,7 @@ class ArrayLoader implements LoaderInterface
}
}
if (isset($config['default_branch']) && $config['default_branch'] === true) {
if (isset($config['default-branch']) && $config['default-branch'] === true) {
return VersionParser::DEV_MASTER_ALIAS;
}
}

View File

@ -231,8 +231,8 @@ class VcsRepository extends ArrayRepository implements ConfigurableRepositoryInt
$data['version'] = preg_replace('{[.-]?dev$}i', '', $data['version']);
$data['version_normalized'] = preg_replace('{(^dev-|[.-]?dev$)}i', '', $data['version_normalized']);
// make sure tag do not contain the default_branch marker
unset($data['default_branch']);
// make sure tag do not contain the default-branch marker
unset($data['default-branch']);
// broken package, version doesn't match tag
if ($data['version_normalized'] !== $parsedTag) {
@ -337,9 +337,9 @@ class VcsRepository extends ArrayRepository implements ConfigurableRepositoryInt
$data['version'] = $version;
$data['version_normalized'] = $parsedBranch;
unset($data['default_branch']);
unset($data['default-branch']);
if ($driver->getRootIdentifier() === $branch) {
$data['default_branch'] = true;
$data['default-branch'] = true;
}
if ($isVeryVerbose) {
@ -446,9 +446,9 @@ class VcsRepository extends ArrayRepository implements ConfigurableRepositoryInt
$this->io->overwriteError($msg, false);
}
unset($cachedPackage['default_branch']);
unset($cachedPackage['default-branch']);
if ($isDefaultBranch) {
$cachedPackage['default_branch'] = true;
$cachedPackage['default-branch'] = true;
}
if ($existingPackage = $this->findPackage($cachedPackage['name'], new Constraint('=', $cachedPackage['version_normalized']))) {