From 10667db1ba369254e6a7d0231bff139fedb6fc80 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Wed, 10 Jan 2024 13:42:01 +0100 Subject: [PATCH] Only override ist url if it is not handled gracefully already --- src/Composer/DependencyResolver/LockTransaction.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Composer/DependencyResolver/LockTransaction.php b/src/Composer/DependencyResolver/LockTransaction.php index 2cfc08239..d5ff59135 100644 --- a/src/Composer/DependencyResolver/LockTransaction.php +++ b/src/Composer/DependencyResolver/LockTransaction.php @@ -15,6 +15,7 @@ namespace Composer\DependencyResolver; use Composer\Package\AliasPackage; use Composer\Package\BasePackage; use Composer\Package\Package; +use Composer\Pcre\Preg; /** * @author Nils Adermann @@ -111,7 +112,10 @@ class LockTransaction extends Transaction if ($package->getName() === $presentPackage->getName() && $package->getVersion() === $presentPackage->getVersion()) { if ($presentPackage->getSourceReference() && $presentPackage->getSourceType() === $package->getSourceType()) { $package->setSourceDistReferences($presentPackage->getSourceReference()); - $package->setDistUrl($presentPackage->getDistUrl()); + // if the dist url is not one of those handled gracefully by setSourceDistReferences then we should overwrite it with the old one + if (!Preg::isMatch('{^https?://(?:(?:www\.)?bitbucket\.org|(api\.)?github\.com|(?:www\.)?gitlab\.com)/}i', $package->getDistUrl())) { + $package->setDistUrl($presentPackage->getDistUrl()); + } $package->setDistType($presentPackage->getDistType()); if ($package instanceof Package) { $package->setDistSha1Checksum($presentPackage->getDistSha1Checksum());