1
0
Fork 0

Display branches and tags if verbose is specified

pull/8137/head
Sam L 2019-05-01 11:25:26 -04:00 committed by Rob
parent 5d615a16d1
commit 8288d2c456
1 changed files with 32 additions and 29 deletions

View File

@ -30,7 +30,8 @@ class VcsRepository extends ArrayRepository implements ConfigurableRepositoryInt
{
protected $url;
protected $packageName;
protected $verbose;
protected $isVerbose;
protected $isVeryVerbose;
protected $io;
protected $config;
protected $versionParser;
@ -64,7 +65,8 @@ class VcsRepository extends ArrayRepository implements ConfigurableRepositoryInt
$this->url = $repoConfig['url'];
$this->io = $io;
$this->type = isset($repoConfig['type']) ? $repoConfig['type'] : 'vcs';
$this->verbose = $io->isVeryVerbose();
$this->isVerbose = $io->isVerbose();
$this->isVeryVerbose = $io->isVeryVerbose();
$this->config = $config;
$this->repoConfig = $repoConfig;
$this->versionCache = $versionCache;
@ -127,7 +129,8 @@ class VcsRepository extends ArrayRepository implements ConfigurableRepositoryInt
{
parent::initialize();
$verbose = $this->verbose;
$isVerbose = $this->isVerbose;
$isVeryVerbose = $this->isVeryVerbose;
$driver = $this->getDriver();
if (!$driver) {
@ -145,23 +148,23 @@ class VcsRepository extends ArrayRepository implements ConfigurableRepositoryInt
$this->packageName = !empty($data['name']) ? $data['name'] : null;
}
} catch (\Exception $e) {
if ($verbose) {
if ($isVeryVerbose) {
$this->io->writeError('<error>Skipped parsing '.$driver->getRootIdentifier().', '.$e->getMessage().'</error>');
}
}
foreach ($driver->getTags() as $tag => $identifier) {
$msg = 'Reading composer.json of <info>' . ($this->packageName ?: $this->url) . '</info> (<comment>' . $tag . '</comment>)';
if ($verbose) {
if ($isVeryVerbose) {
$this->io->writeError($msg);
} else {
} elseif ($isVerbose) {
$this->io->overwriteError($msg, false);
}
// strip the release- prefix from tags if present
$tag = str_replace('release-', '', $tag);
$cachedPackage = $this->getCachedPackageVersion($tag, $identifier, $verbose);
$cachedPackage = $this->getCachedPackageVersion($tag, $identifier, $isVerbose, $isVeryVerbose);
if ($cachedPackage) {
$this->addPackage($cachedPackage);
@ -173,7 +176,7 @@ class VcsRepository extends ArrayRepository implements ConfigurableRepositoryInt
}
if (!$parsedTag = $this->validateTag($tag)) {
if ($verbose) {
if ($isVeryVerbose) {
$this->io->writeError('<warning>Skipped tag '.$tag.', invalid tag name</warning>');
}
continue;
@ -181,7 +184,7 @@ class VcsRepository extends ArrayRepository implements ConfigurableRepositoryInt
try {
if (!$data = $driver->getComposerInformation($identifier)) {
if ($verbose) {
if ($isVeryVerbose) {
$this->io->writeError('<warning>Skipped tag '.$tag.', no composer file</warning>');
}
$this->emptyReferences[] = $identifier;
@ -203,7 +206,7 @@ class VcsRepository extends ArrayRepository implements ConfigurableRepositoryInt
// broken package, version doesn't match tag
if ($data['version_normalized'] !== $parsedTag) {
if ($verbose) {
if ($isVeryVerbose) {
$this->io->writeError('<warning>Skipped tag '.$tag.', tag ('.$parsedTag.') does not match version ('.$data['version_normalized'].') in composer.json</warning>');
}
continue;
@ -211,13 +214,13 @@ class VcsRepository extends ArrayRepository implements ConfigurableRepositoryInt
$tagPackageName = isset($data['name']) ? $data['name'] : $this->packageName;
if ($existingPackage = $this->findPackage($tagPackageName, $data['version_normalized'])) {
if ($verbose) {
if ($isVeryVerbose) {
$this->io->writeError('<warning>Skipped tag '.$tag.', it conflicts with an another tag ('.$existingPackage->getPrettyVersion().') as both resolve to '.$data['version_normalized'].' internally</warning>');
}
continue;
}
if ($verbose) {
if ($isVeryVerbose) {
$this->io->writeError('Importing tag '.$tag.' ('.$data['version_normalized'].')');
}
@ -226,35 +229,35 @@ class VcsRepository extends ArrayRepository implements ConfigurableRepositoryInt
if ($e instanceof TransportException && $e->getCode() === 404) {
$this->emptyReferences[] = $identifier;
}
if ($verbose) {
if ($isVeryVerbose) {
$this->io->writeError('<warning>Skipped tag '.$tag.', '.($e instanceof TransportException ? 'no composer file was found' : $e->getMessage()).'</warning>');
}
continue;
}
}
if (!$verbose) {
if (!$isVeryVerbose) {
$this->io->overwriteError('', false);
}
$branches = $driver->getBranches();
foreach ($branches as $branch => $identifier) {
$msg = 'Reading composer.json of <info>' . ($this->packageName ?: $this->url) . '</info> (<comment>' . $branch . '</comment>)';
if ($verbose) {
if ($isVeryVerbose) {
$this->io->writeError($msg);
} else {
} elseif ($isVerbose) {
$this->io->overwriteError($msg, false);
}
if ($branch === 'trunk' && isset($branches['master'])) {
if ($verbose) {
if ($isVeryVerbose) {
$this->io->writeError('<warning>Skipped branch '.$branch.', can not parse both master and trunk branches as they both resolve to 9999999-dev internally</warning>');
}
continue;
}
if (!$parsedBranch = $this->validateBranch($branch)) {
if ($verbose) {
if ($isVeryVerbose) {
$this->io->writeError('<warning>Skipped branch '.$branch.', invalid name</warning>');
}
continue;
@ -268,7 +271,7 @@ class VcsRepository extends ArrayRepository implements ConfigurableRepositoryInt
$version = $prefix . preg_replace('{(\.9{7})+}', '.x', $parsedBranch);
}
$cachedPackage = $this->getCachedPackageVersion($version, $identifier, $verbose);
$cachedPackage = $this->getCachedPackageVersion($version, $identifier, $isVerbose, $isVeryVerbose);
if ($cachedPackage) {
$this->addPackage($cachedPackage);
@ -281,7 +284,7 @@ class VcsRepository extends ArrayRepository implements ConfigurableRepositoryInt
try {
if (!$data = $driver->getComposerInformation($identifier)) {
if ($verbose) {
if ($isVeryVerbose) {
$this->io->writeError('<warning>Skipped branch '.$branch.', no composer file</warning>');
}
$this->emptyReferences[] = $identifier;
@ -292,7 +295,7 @@ class VcsRepository extends ArrayRepository implements ConfigurableRepositoryInt
$data['version'] = $version;
$data['version_normalized'] = $parsedBranch;
if ($verbose) {
if ($isVeryVerbose) {
$this->io->writeError('Importing branch '.$branch.' ('.$data['version'].')');
}
@ -306,12 +309,12 @@ class VcsRepository extends ArrayRepository implements ConfigurableRepositoryInt
if ($e->getCode() === 404) {
$this->emptyReferences[] = $identifier;
}
if ($verbose) {
if ($isVeryVerbose) {
$this->io->writeError('<warning>Skipped branch '.$branch.', no composer file was found</warning>');
}
continue;
} catch (\Exception $e) {
if (!$verbose) {
if (!$isVeryVerbose) {
$this->io->writeError('');
}
$this->branchErrorOccurred = true;
@ -322,7 +325,7 @@ class VcsRepository extends ArrayRepository implements ConfigurableRepositoryInt
}
$driver->cleanup();
if (!$verbose) {
if (!$isVeryVerbose) {
$this->io->overwriteError('', false);
}
@ -367,7 +370,7 @@ class VcsRepository extends ArrayRepository implements ConfigurableRepositoryInt
return false;
}
private function getCachedPackageVersion($version, $identifier, $verbose)
private function getCachedPackageVersion($version, $identifier, $isVerbose, $isVeryVerbose)
{
if (!$this->versionCache) {
return;
@ -375,7 +378,7 @@ class VcsRepository extends ArrayRepository implements ConfigurableRepositoryInt
$cachedPackage = $this->versionCache->getVersionPackage($version, $identifier);
if ($cachedPackage === false) {
if ($verbose) {
if ($isVeryVerbose) {
$this->io->writeError('<warning>Skipped '.$version.', no composer file (cached from ref '.$identifier.')</warning>');
}
@ -384,14 +387,14 @@ class VcsRepository extends ArrayRepository implements ConfigurableRepositoryInt
if ($cachedPackage) {
$msg = 'Found cached composer.json of <info>' . ($this->packageName ?: $this->url) . '</info> (<comment>' . $version . '</comment>)';
if ($verbose) {
if ($isVeryVerbose) {
$this->io->writeError($msg);
} else {
} elseif ($isVerbose) {
$this->io->overwriteError($msg, false);
}
if ($existingPackage = $this->findPackage($cachedPackage['name'], $cachedPackage['version_normalized'])) {
if ($verbose) {
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>');
}
$cachedPackage = null;