1
0
Fork 0

Allow filtering of warning/info msgs by composer version

pull/8017/head
Jordi Boggiano 2019-02-21 14:05:56 +01:00
parent 4271167495
commit 0f36a42d61
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC
1 changed files with 23 additions and 12 deletions

View File

@ -20,6 +20,7 @@ use Composer\DependencyResolver\Pool;
use Composer\Json\JsonFile;
use Composer\Cache;
use Composer\Config;
use Composer\Composer;
use Composer\Factory;
use Composer\IO\IOInterface;
use Composer\Util\RemoteFilesystem;
@ -699,12 +700,7 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
}
$data = JsonFile::parseJson($json, $filename);
if (!empty($data['warning'])) {
$this->io->writeError('<warning>Warning from '.$this->url.': '.$data['warning'].'</warning>');
}
if (!empty($data['info'])) {
$this->io->writeError('<info>Info from '.$this->url.': '.$data['info'].'</info>');
}
$this->outputWarnings($data);
if ($cacheKey) {
if ($storeLastModifiedTime) {
@ -769,12 +765,7 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
}
$data = JsonFile::parseJson($json, $filename);
if (!empty($data['warning'])) {
$this->io->writeError('<warning>Warning from '.$this->url.': '.$data['warning'].'</warning>');
}
if (!empty($data['info'])) {
$this->io->writeError('<info>Info from '.$this->url.': '.$data['info'].'</info>');
}
$this->outputWarnings($data);
$lastModifiedDate = $rfs->findHeaderValue($rfs->getLastHeaders(), 'last-modified');
if ($lastModifiedDate) {
@ -835,4 +826,24 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
// wipe rootData as it is fully consumed at this point and this saves some memory
$this->rootData = true;
}
private function outputWarnings($data)
{
foreach (array('warning', 'info') as $type) {
if (empty($data[$type])) {
continue;
}
if (!empty($data[$type . '-versions'])) {
$versionParser = new VersionParser();
$constraint = $versionParser->parseConstraints($data[$type . '-versions']);
$composer = new Constraint('==', $versionParser->normalize(Composer::getVersion()));
if (!$constraint->matches($composer)) {
continue;
}
}
$this->io->writeError('<'.$type.'>'.ucfirst($type).' from '.$this->url.': '.$data[$type].'</'.$type.'>');
}
}
}