1
0
Fork 0

Avoid warning about --2 usage when no channel is requested

pull/8767/head
Jordi Boggiano 2020-04-09 16:25:10 +02:00
parent a4cd422a52
commit f70b3b0152
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC
1 changed files with 4 additions and 2 deletions

View File

@ -84,8 +84,10 @@ EOT
$versionsUtil = new Versions($config, $remoteFilesystem); $versionsUtil = new Versions($config, $remoteFilesystem);
// switch channel if requested // switch channel if requested
$requestedChannel = null;
foreach (Versions::CHANNELS as $channel) { foreach (Versions::CHANNELS as $channel) {
if ($input->getOption($channel)) { if ($input->getOption($channel)) {
$requestedChannel = $channel;
$versionsUtil->setChannel($channel); $versionsUtil->setChannel($channel);
break; break;
} }
@ -130,8 +132,8 @@ EOT
$latestVersion = $latest['version']; $latestVersion = $latest['version'];
$updateVersion = $input->getArgument('version') ?: $latestVersion; $updateVersion = $input->getArgument('version') ?: $latestVersion;
if (is_numeric($channel) && substr($latestStable['version'], 0, 1) !== $channel) { if ($requestedChannel && is_numeric($requestedChannel) && substr($latestStable['version'], 0, 1) !== $requestedChannel) {
$io->writeError('<warning>Warning: You forced the install of '.$latestVersion.' via --'.$channel.', but '.$latestStable['version'].' is the latest stable version. Updating to it via composer self-update --stable is recommended.</warning>'); $io->writeError('<warning>Warning: You forced the install of '.$latestVersion.' via --'.$requestedChannel.', but '.$latestStable['version'].' is the latest stable version. Updating to it via composer self-update --stable is recommended.</warning>');
} }
if (preg_match('{^[0-9a-f]{40}$}', $updateVersion) && $updateVersion !== $latestVersion) { if (preg_match('{^[0-9a-f]{40}$}', $updateVersion) && $updateVersion !== $latestVersion) {