Merge branch '1.10'
commit
2d3905157d
|
@ -135,8 +135,36 @@ EOT
|
|||
|
||||
$latest = $versionsUtil->getLatest();
|
||||
$latestStable = $versionsUtil->getLatest('stable');
|
||||
try {
|
||||
$latestPreview = $versionsUtil->getLatest('preview');
|
||||
} catch (\UnexpectedValueException $e) {
|
||||
$latestPreview = $latestStable;
|
||||
}
|
||||
$latestVersion = $latest['version'];
|
||||
$updateVersion = $input->getArgument('version') ?: $latestVersion;
|
||||
$currentMajorVersion = preg_replace('{^(\d+).*}', '$1', Composer::getVersion());
|
||||
$updateMajorVersion = preg_replace('{^(\d+).*}', '$1', $updateVersion);
|
||||
$previewMajorVersion = preg_replace('{^(\d+).*}', '$1', $latestPreview['version']);
|
||||
|
||||
if ($versionsUtil->getChannel() === 'stable' && !$input->getArgument('version')) {
|
||||
// if requesting stable channel and no specific version, avoid automatically upgrading to the next major
|
||||
// simply output a warning that the next major stable is available and let users upgrade to it manually
|
||||
if ($currentMajorVersion < $updateMajorVersion) {
|
||||
$skippedVersion = $updateVersion;
|
||||
|
||||
$versionsUtil->setChannel($currentMajorVersion);
|
||||
|
||||
$latest = $versionsUtil->getLatest();
|
||||
$latestStable = $versionsUtil->getLatest('stable');
|
||||
$latestVersion = $latest['version'];
|
||||
$updateVersion = $latestVersion;
|
||||
|
||||
$io->writeError('<warning>A new stable major version of Composer is available ('.$skippedVersion.'), run "composer self-update --'.$updateMajorVersion.'" to update to it. See also https://github.com/composer/composer/releases for changelogs.</warning>');
|
||||
} elseif ($currentMajorVersion < $previewMajorVersion) {
|
||||
// promote next major version if available in preview
|
||||
$io->writeError('<warning>A preview release of the next major version of Composer is available ('.$latestPreview['version'].'), run "composer self-update --preview" to give it a try. See also https://github.com/composer/composer/releases for changelogs.</warning>');
|
||||
}
|
||||
}
|
||||
|
||||
if ($requestedChannel && is_numeric($requestedChannel) && substr($latestStable['version'], 0, 1) !== $requestedChannel) {
|
||||
$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>');
|
||||
|
|
|
@ -60,7 +60,7 @@ class DefaultPolicy implements PolicyInterface
|
|||
$sortedLiterals = $this->pruneRemoteAliases($pool, $sortedLiterals);
|
||||
}
|
||||
|
||||
$selected = \call_user_func_array('array_merge', $packages);
|
||||
$selected = \call_user_func_array('array_merge', array_values($packages));
|
||||
|
||||
// now sort the result across all packages to respect replaces across packages
|
||||
usort($selected, function ($a, $b) use ($policy, $pool, $requiredPackage) {
|
||||
|
|
|
@ -120,11 +120,15 @@ abstract class BitbucketDriver extends VcsDriver
|
|||
|
||||
if (!isset($this->infoCache[$identifier])) {
|
||||
if ($this->shouldCache($identifier) && $res = $this->cache->read($identifier)) {
|
||||
return $this->infoCache[$identifier] = JsonFile::parseJson($res);
|
||||
}
|
||||
|
||||
$composer = JsonFile::parseJson($res);
|
||||
} else {
|
||||
$composer = $this->getBaseComposerInformation($identifier);
|
||||
|
||||
if ($this->shouldCache($identifier)) {
|
||||
$this->cache->write($identifier, json_encode($composer));
|
||||
}
|
||||
}
|
||||
|
||||
if ($composer) {
|
||||
// specials for bitbucket
|
||||
if (!isset($composer['support']['source'])) {
|
||||
|
@ -174,10 +178,6 @@ abstract class BitbucketDriver extends VcsDriver
|
|||
}
|
||||
|
||||
$this->infoCache[$identifier] = $composer;
|
||||
|
||||
if ($this->shouldCache($identifier)) {
|
||||
$this->cache->write($identifier, json_encode($composer));
|
||||
}
|
||||
}
|
||||
|
||||
return $this->infoCache[$identifier];
|
||||
|
|
|
@ -151,11 +151,15 @@ class GitHubDriver extends VcsDriver
|
|||
|
||||
if (!isset($this->infoCache[$identifier])) {
|
||||
if ($this->shouldCache($identifier) && $res = $this->cache->read($identifier)) {
|
||||
return $this->infoCache[$identifier] = JsonFile::parseJson($res);
|
||||
}
|
||||
|
||||
$composer = JsonFile::parseJson($res);
|
||||
} else {
|
||||
$composer = $this->getBaseComposerInformation($identifier);
|
||||
|
||||
if ($this->shouldCache($identifier)) {
|
||||
$this->cache->write($identifier, json_encode($composer));
|
||||
}
|
||||
}
|
||||
|
||||
if ($composer) {
|
||||
// specials for github
|
||||
if (!isset($composer['support']['source'])) {
|
||||
|
@ -173,10 +177,6 @@ class GitHubDriver extends VcsDriver
|
|||
}
|
||||
}
|
||||
|
||||
if ($this->shouldCache($identifier)) {
|
||||
$this->cache->write($identifier, json_encode($composer));
|
||||
}
|
||||
|
||||
$this->infoCache[$identifier] = $composer;
|
||||
}
|
||||
|
||||
|
|
|
@ -131,11 +131,15 @@ class GitLabDriver extends VcsDriver
|
|||
|
||||
if (!isset($this->infoCache[$identifier])) {
|
||||
if ($this->shouldCache($identifier) && $res = $this->cache->read($identifier)) {
|
||||
return $this->infoCache[$identifier] = JsonFile::parseJson($res);
|
||||
}
|
||||
|
||||
$composer = JsonFile::parseJson($res);
|
||||
} else {
|
||||
$composer = $this->getBaseComposerInformation($identifier);
|
||||
|
||||
if ($this->shouldCache($identifier)) {
|
||||
$this->cache->write($identifier, json_encode($composer));
|
||||
}
|
||||
}
|
||||
|
||||
if ($composer) {
|
||||
// specials for gitlab (this data is only available if authentication is provided)
|
||||
if (!isset($composer['support']['issues']) && isset($this->project['_links']['issues'])) {
|
||||
|
@ -146,10 +150,6 @@ class GitLabDriver extends VcsDriver
|
|||
}
|
||||
}
|
||||
|
||||
if ($this->shouldCache($identifier)) {
|
||||
$this->cache->write($identifier, json_encode($composer));
|
||||
}
|
||||
|
||||
$this->infoCache[$identifier] = $composer;
|
||||
}
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ class Versions
|
|||
private $httpDownloader;
|
||||
private $config;
|
||||
private $channel;
|
||||
private $versionsData;
|
||||
|
||||
public function __construct(Config $config, HttpDownloader $httpDownloader)
|
||||
{
|
||||
|
@ -63,12 +64,7 @@ class Versions
|
|||
|
||||
public function getLatest($channel = null)
|
||||
{
|
||||
if ($this->config->get('disable-tls') === true) {
|
||||
$protocol = 'http';
|
||||
} else {
|
||||
$protocol = 'https';
|
||||
}
|
||||
$versions = $this->httpDownloader->get($protocol . '://getcomposer.org/versions')->decodeJson();
|
||||
$versions = $this->getVersionsData();
|
||||
|
||||
foreach ($versions[$channel ?: $this->getChannel()] as $version) {
|
||||
if ($version['min-php'] <= PHP_VERSION_ID) {
|
||||
|
@ -76,6 +72,21 @@ class Versions
|
|||
}
|
||||
}
|
||||
|
||||
throw new \LogicException('There is no version of Composer available for your PHP version ('.PHP_VERSION.')');
|
||||
throw new \UnexpectedValueException('There is no version of Composer available for your PHP version ('.PHP_VERSION.')');
|
||||
}
|
||||
|
||||
private function getVersionsData()
|
||||
{
|
||||
if (!$this->versionsData) {
|
||||
if ($this->config->get('disable-tls') === true) {
|
||||
$protocol = 'http';
|
||||
} else {
|
||||
$protocol = 'https';
|
||||
}
|
||||
|
||||
$this->versionsData = $this->httpDownloader->get($protocol . '://getcomposer.org/versions')->decodeJson();
|
||||
}
|
||||
|
||||
return $this->versionsData;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue