diff --git a/src/Composer/Installer.php b/src/Composer/Installer.php index dbdcb048d..0d842bb53 100644 --- a/src/Composer/Installer.php +++ b/src/Composer/Installer.php @@ -1184,9 +1184,9 @@ class Installer $package->setSourceReference($sourceReference); } - // only update dist url for github/bitbucket dists as they use a combination of dist url + dist reference to install + // only update dist url for github/bitbucket/gitlab dists as they use a combination of dist url + dist reference to install // but for other urls this is ambiguous and could result in bad outcomes - if (preg_match('{^https?://(?:(?:www\.)?bitbucket\.org|(api\.)?github\.com)/}i', $distUrl)) { + if (preg_match('{^https?://(?:(?:www\.)?bitbucket\.org|(api\.)?github\.com|(?:www\.)?gitlab\.com)/}i', $distUrl)) { $package->setDistUrl($distUrl); $this->updateInstallReferences($package, $sourceReference); } @@ -1204,9 +1204,9 @@ class Installer $package->setSourceReference($reference); - if (preg_match('{^https?://(?:(?:www\.)?bitbucket\.org|(api\.)?github\.com)/}i', $package->getDistUrl())) { + if (preg_match('{^https?://(?:(?:www\.)?bitbucket\.org|(api\.)?github\.com|(?:www\.)?gitlab\.com)/}i', $package->getDistUrl())) { $package->setDistReference($reference); - $package->setDistUrl(preg_replace('{(?<=/)[a-f0-9]{40}(?=/|$)}i', $reference, $package->getDistUrl())); + $package->setDistUrl(preg_replace('{(?<=/|sha=)[a-f0-9]{40}(?=/|$)}i', $reference, $package->getDistUrl())); } elseif ($package->getDistReference()) { // update the dist reference if there was one, but if none was provided ignore it $package->setDistReference($reference); }