1
0
Fork 0

Reflow the VcsRepo and prevent exception leakage from breaking the parsing

pull/421/merge
Jordi Boggiano 2012-03-10 00:10:41 +01:00
parent a4f9e03d35
commit 950003bfc3
1 changed files with 85 additions and 65 deletions

View File

@ -83,10 +83,16 @@ class VcsRepository extends ArrayRepository
$this->versionParser = new VersionParser;
$loader = new ArrayLoader();
try {
if ($driver->hasComposerFile($driver->getRootIdentifier())) {
$data = $driver->getComposerInformation($driver->getRootIdentifier());
$this->packageName = !empty($data['name']) ? $data['name'] : null;
}
} catch (\Exception $e) {
if ($debug) {
$this->io->write('Skipped parsing '.$driver->getRootIdentifier().', '.$e->getMessage());
}
}
foreach ($driver->getTags() as $tag => $identifier) {
$msg = 'Get composer info for <info>' . $this->packageName . '</info> (<comment>' . $tag . '</comment>)';
@ -96,18 +102,25 @@ class VcsRepository extends ArrayRepository
$this->io->overwrite($msg, false);
}
$parsedTag = $this->validateTag($tag);
if ($parsedTag && $driver->hasComposerFile($identifier)) {
if (!$parsedTag = $this->validateTag($tag)) {
if ($debug) {
$this->io->write('Skipped tag '.$tag.', invalid tag name');
}
continue;
}
try {
$data = $driver->getComposerInformation($identifier);
} catch (TransportException $e) {
if (!$data = $driver->getComposerInformation($identifier)) {
if ($debug) {
$this->io->write('Skipped tag '.$tag.', no composer file');
}
continue;
}
} catch (\Exception $e) {
if ($debug) {
$this->io->write('Skipped tag '.$tag.', '.$e->getMessage());
}
continue;
} catch (\Exception $e) {
$this->io->write('Skipped tag '.$tag.', '.$e->getMessage());
continue;
}
// manually versioned package
@ -136,9 +149,6 @@ class VcsRepository extends ArrayRepository
}
$this->addPackage($loader->load($this->preProcess($driver, $data, $identifier)));
} elseif ($debug) {
$this->io->write('Skipped tag '.$tag.', '.($parsedTag ? 'no composer file was found' : 'invalid name'));
}
}
$this->io->overwrite('', false);
@ -151,17 +161,30 @@ class VcsRepository extends ArrayRepository
$this->io->overwrite($msg, false);
}
$parsedBranch = $this->validateBranch($branch);
if ($driver->hasComposerFile($identifier)) {
$data = $driver->getComposerInformation($identifier);
if (!$parsedBranch) {
if (!$parsedBranch = $this->validateBranch($branch)) {
if ($debug) {
$this->io->write('Skipped branch '.$branch.', invalid name and no composer file was found');
$this->io->write('Skipped branch '.$branch.', invalid name');
}
continue;
}
try {
if (!$data = $driver->getComposerInformation($identifier)) {
if ($debug) {
$this->io->write('Skipped branch '.$branch.', no composer file');
}
continue;
}
} catch (TransportException $e) {
if ($debug) {
$this->io->write('Skipped branch '.$branch.', no composer file was found');
}
continue;
} catch (\Exception $e) {
$this->io->write('Skipped branch '.$branch.', '.$e->getMessage());
continue;
}
// branches are always auto-versionned, read value from branch name
$data['version'] = $branch;
$data['version_normalized'] = $parsedBranch;
@ -178,9 +201,6 @@ class VcsRepository extends ArrayRepository
}
$this->addPackage($loader->load($this->preProcess($driver, $data, $identifier)));
} elseif ($debug) {
$this->io->write('Skipped branch '.$branch.', no composer file was found');
}
}
$this->io->overwrite('', false);