From a180f4892167590be776e58eef2318b55a6ebc0f Mon Sep 17 00:00:00 2001 From: Ion Bazan Date: Tue, 11 Feb 2020 16:35:35 +0800 Subject: [PATCH] Distinguish between updates and downgrades in dry-run --- .../DependencyResolver/Operation/UpdateOperation.php | 5 ++++- .../partial-update-downgrades-non-whitelisted-unstable.test | 2 +- .../Test/Fixtures/installer/partial-update-from-lock.test | 4 ++-- .../Test/Fixtures/installer/partial-update-without-lock.test | 2 +- .../installer/update-downgrades-unstable-packages.test | 2 +- .../Test/Fixtures/installer/update-prefer-lowest-stable.test | 2 +- 6 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/Composer/DependencyResolver/Operation/UpdateOperation.php b/src/Composer/DependencyResolver/Operation/UpdateOperation.php index 836725ef5..8cfc6b700 100644 --- a/src/Composer/DependencyResolver/Operation/UpdateOperation.php +++ b/src/Composer/DependencyResolver/Operation/UpdateOperation.php @@ -13,6 +13,7 @@ namespace Composer\DependencyResolver\Operation; use Composer\Package\PackageInterface; +use Composer\Package\Version\VersionParser; /** * Solver update operation. @@ -74,7 +75,9 @@ class UpdateOperation extends SolverOperation */ public function __toString() { - return 'Updating '.$this->initialPackage->getPrettyName().' ('.$this->formatVersion($this->initialPackage).') to '. + $actionName = VersionParser::isUpgrade($this->initialPackage->getVersion(), $this->targetPackage->getVersion()) ? 'Updating' : 'Downgrading'; + + return $actionName.' '.$this->initialPackage->getPrettyName().' ('.$this->formatVersion($this->initialPackage).') to '. $this->targetPackage->getPrettyName(). ' ('.$this->formatVersion($this->targetPackage).')'; } } diff --git a/tests/Composer/Test/Fixtures/installer/partial-update-downgrades-non-whitelisted-unstable.test b/tests/Composer/Test/Fixtures/installer/partial-update-downgrades-non-whitelisted-unstable.test index 9b8d32f06..3a428c97c 100644 --- a/tests/Composer/Test/Fixtures/installer/partial-update-downgrades-non-whitelisted-unstable.test +++ b/tests/Composer/Test/Fixtures/installer/partial-update-downgrades-non-whitelisted-unstable.test @@ -66,6 +66,6 @@ update c/uptodate "platform-dev": [] } --EXPECT-- -Updating b/unstable (1.1.0-alpha) to b/unstable (1.0.0) +Downgrading b/unstable (1.1.0-alpha) to b/unstable (1.0.0) Updating a/old (0.9.0) to a/old (1.0.0) Installing d/removed (1.0.0) diff --git a/tests/Composer/Test/Fixtures/installer/partial-update-from-lock.test b/tests/Composer/Test/Fixtures/installer/partial-update-from-lock.test index ed2002e4e..a54d66ee9 100644 --- a/tests/Composer/Test/Fixtures/installer/partial-update-from-lock.test +++ b/tests/Composer/Test/Fixtures/installer/partial-update-from-lock.test @@ -74,8 +74,8 @@ update b/unstable "platform-dev": [] } --EXPECT-- -Updating b/unstable (1.1.0-alpha) to b/unstable (1.0.0) +Downgrading b/unstable (1.1.0-alpha) to b/unstable (1.0.0) Updating a/old (0.9.0) to a/old (1.0.0) -Updating c/uptodate (2.0.0) to c/uptodate (1.0.0) +Downgrading c/uptodate (2.0.0) to c/uptodate (1.0.0) Installing d/removed (1.0.0) Installing e/newreq (1.0.0) diff --git a/tests/Composer/Test/Fixtures/installer/partial-update-without-lock.test b/tests/Composer/Test/Fixtures/installer/partial-update-without-lock.test index e931a1f7d..94be9176c 100644 --- a/tests/Composer/Test/Fixtures/installer/partial-update-without-lock.test +++ b/tests/Composer/Test/Fixtures/installer/partial-update-without-lock.test @@ -48,4 +48,4 @@ update b/unstable "platform-dev": [] } --EXPECT-- -Updating b/unstable (1.1.0-alpha) to b/unstable (1.0.0) +Downgrading b/unstable (1.1.0-alpha) to b/unstable (1.0.0) diff --git a/tests/Composer/Test/Fixtures/installer/update-downgrades-unstable-packages.test b/tests/Composer/Test/Fixtures/installer/update-downgrades-unstable-packages.test index 1b6e55ef9..0cb42e6fa 100644 --- a/tests/Composer/Test/Fixtures/installer/update-downgrades-unstable-packages.test +++ b/tests/Composer/Test/Fixtures/installer/update-downgrades-unstable-packages.test @@ -46,4 +46,4 @@ Downgrading from unstable to more stable package should work even if already ins --RUN-- update --EXPECT-- -Updating a/a (dev-master abcd) to a/a (1.0.0) +Downgrading a/a (dev-master abcd) to a/a (1.0.0) diff --git a/tests/Composer/Test/Fixtures/installer/update-prefer-lowest-stable.test b/tests/Composer/Test/Fixtures/installer/update-prefer-lowest-stable.test index 00efd5688..68e3effe2 100644 --- a/tests/Composer/Test/Fixtures/installer/update-prefer-lowest-stable.test +++ b/tests/Composer/Test/Fixtures/installer/update-prefer-lowest-stable.test @@ -37,4 +37,4 @@ Updates packages to their lowest stable version update --prefer-lowest --prefer-stable --EXPECT-- Updating a/a (1.0.0-rc1) to a/a (1.0.1) -Updating a/b (1.0.1) to a/b (1.0.0) +Downgrading a/b (1.0.1) to a/b (1.0.0)