From 9b0f9b40a44a8ed0f5a34bb2674b95561b5039d2 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Tue, 19 Dec 2023 17:17:48 +0100 Subject: [PATCH] Show package source in very verbose updates, fixes #11733 (#11763) --- src/Composer/Installer.php | 9 ++++++- .../Test/Command/UpdateCommandTest.php | 25 ++++++++++++++++++- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/src/Composer/Installer.php b/src/Composer/Installer.php index d974f8c29..b4361a102 100644 --- a/src/Composer/Installer.php +++ b/src/Composer/Installer.php @@ -605,7 +605,14 @@ class Installer // output op if lock file is enabled, but alias op only in debug verbosity if ($this->config->get('lock') && (false === strpos($operation->getOperationType(), 'Alias') || $this->io->isDebug())) { - $this->io->writeError(' - ' . $operation->show(true)); + $sourceRepo = ''; + if ($this->io->isVeryVerbose() && false === strpos($operation->getOperationType(), 'Alias')) { + $operationPkg = ($operation instanceof UpdateOperation ? $operation->getTargetPackage() : $operation->getPackage()); + if ($operationPkg->getRepository() !== null) { + $sourceRepo = ' from ' . $operationPkg->getRepository()->getRepoName(); + } + } + $this->io->writeError(' - ' . $operation->show(true) . $sourceRepo); } } diff --git a/tests/Composer/Test/Command/UpdateCommandTest.php b/tests/Composer/Test/Command/UpdateCommandTest.php index cf84015e1..fce735087 100644 --- a/tests/Composer/Test/Command/UpdateCommandTest.php +++ b/tests/Composer/Test/Command/UpdateCommandTest.php @@ -29,7 +29,7 @@ class UpdateCommandTest extends TestCase $appTester = $this->getApplicationTester(); $appTester->run(array_merge(['command' => 'update', '--dry-run' => true, '--no-audit' => true], $command)); - $this->assertSame(trim($expected), trim($appTester->getDisplay(true))); + $this->assertStringMatchesFormat(trim($expected), trim($appTester->getDisplay(true))); } public static function provideUpdates(): \Generator @@ -67,6 +67,29 @@ Package operations: 2 installs, 0 updates, 0 removals OUTPUT ]; + yield 'simple update with very verbose output' => [ + $rootDepAndTransitiveDep, + ['-vv' => true], + << [ $rootDepAndTransitiveDep, ['--with' => ['dep/pkg:1.0.0'], '--no-install' => true],