1
0
Fork 0

Support also default_branch flag in cached versions

pull/8995/head
Jordi Boggiano 2020-06-19 09:45:39 +02:00
parent 52afa5ef16
commit 4682efcf77
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC
1 changed files with 7 additions and 2 deletions

View File

@ -313,7 +313,7 @@ class VcsRepository extends ArrayRepository implements ConfigurableRepositoryInt
$version = $prefix . preg_replace('{(\.9{7})+}', '.x', $parsedBranch); $version = $prefix . preg_replace('{(\.9{7})+}', '.x', $parsedBranch);
} }
$cachedPackage = $this->getCachedPackageVersion($version, $identifier, $isVerbose, $isVeryVerbose); $cachedPackage = $this->getCachedPackageVersion($version, $identifier, $isVerbose, $isVeryVerbose, $driver->getRootIdentifier() === $branch);
if ($cachedPackage) { if ($cachedPackage) {
$this->addPackage($cachedPackage); $this->addPackage($cachedPackage);
@ -423,7 +423,7 @@ class VcsRepository extends ArrayRepository implements ConfigurableRepositoryInt
return false; return false;
} }
private function getCachedPackageVersion($version, $identifier, $isVerbose, $isVeryVerbose) private function getCachedPackageVersion($version, $identifier, $isVerbose, $isVeryVerbose, $isDefaultBranch = false)
{ {
if (!$this->versionCache) { if (!$this->versionCache) {
return; return;
@ -446,6 +446,11 @@ class VcsRepository extends ArrayRepository implements ConfigurableRepositoryInt
$this->io->overwriteError($msg, false); $this->io->overwriteError($msg, false);
} }
unset($cachedPackage['default_branch']);
if ($isDefaultBranch) {
$cachedPackage['default_branch'] = true;
}
if ($existingPackage = $this->findPackage($cachedPackage['name'], new Constraint('=', $cachedPackage['version_normalized']))) { if ($existingPackage = $this->findPackage($cachedPackage['name'], new Constraint('=', $cachedPackage['version_normalized']))) {
if ($isVeryVerbose) { if ($isVeryVerbose) {
$this->io->writeError('<warning>Skipped cached version '.$version.', it conflicts with an another tag ('.$existingPackage->getPrettyVersion().') as both resolve to '.$cachedPackage['version_normalized'].' internally</warning>'); $this->io->writeError('<warning>Skipped cached version '.$version.', it conflicts with an another tag ('.$existingPackage->getPrettyVersion().') as both resolve to '.$cachedPackage['version_normalized'].' internally</warning>');