From 35b403b26648d3a0a5a126ea8c9f2cfc0e8a816c Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Thu, 19 Nov 2020 09:39:03 +0100 Subject: [PATCH] Make sure a version not found issue is reported as such for clarity, fixes #9500 --- src/Composer/Command/SelfUpdateCommand.php | 9 ++++++++- src/Composer/Compiler.php | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Composer/Command/SelfUpdateCommand.php b/src/Composer/Command/SelfUpdateCommand.php index f638a0f5b..db27e0d28 100644 --- a/src/Composer/Command/SelfUpdateCommand.php +++ b/src/Composer/Command/SelfUpdateCommand.php @@ -21,6 +21,7 @@ use Composer\SelfUpdate\Keys; use Composer\SelfUpdate\Versions; use Composer\IO\IOInterface; use Composer\Downloader\FilesystemException; +use Composer\Downloader\TransportException; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputArgument; @@ -211,7 +212,13 @@ EOT $io->write(sprintf("Upgrading to version %s (%s channel).", $updateVersion, $channelString)); $remoteFilename = $baseUrl . ($updatingToTag ? "/download/{$updateVersion}/composer.phar" : '/composer.phar'); - $signature = $httpDownloader->get($remoteFilename.'.sig')->getBody(); + try { + $signature = $httpDownloader->get($remoteFilename.'.sig')->getBody(); + } catch (TransportException $e) { + if ($e->getStatusCode() === 404) { + throw new \InvalidArgumentException('Version "'.$updateVersion.'" could not be found.', 0, $e); + } + } $io->writeError(' ', false); $httpDownloader->copy($remoteFilename, $tempFilename); $io->writeError(''); diff --git a/src/Composer/Compiler.php b/src/Composer/Compiler.php index 56fdb1e40..2d0c679ae 100644 --- a/src/Composer/Compiler.php +++ b/src/Composer/Compiler.php @@ -110,7 +110,7 @@ class Compiler $finder = new Finder(); $finder->files() ->ignoreVCS(true) - ->notPath('/\/(composer\.(json|lock)|[A-Z]+\.md|\.gitignore|phpunit\.xml\.dist|phpstan\.neon\.dist|phpstan-config\.neon)$/') + ->notPath('/\/(composer\.(json|lock)|[A-Z]+\.md|\.gitignore|appveyor.yml|phpunit\.xml\.dist|phpstan\.neon\.dist|phpstan-config\.neon)$/') ->notPath('/bin\/(jsonlint|validate-json|simple-phpunit)(\.bat)?$/') ->notPath('symfony/debug/Resources/ext/') ->notPath('justinrainbow/json-schema/demo/')