1
0
Fork 0

Add support for gitlab.com URL replacement, fixes #7160

pull/7096/merge
Jordi Boggiano 2018-04-12 10:35:22 +02:00
parent 066351c5b9
commit 4bddcd7124
1 changed files with 4 additions and 4 deletions

View File

@ -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);
}