1
0
Fork 0

Fix updating of dev refs if they are not whitelisted

pull/5221/head
Jordi Boggiano 2016-04-19 20:03:14 +01:00
parent 1bf711fe1f
commit c7c8335b8b
2 changed files with 33 additions and 8 deletions

View File

@ -1003,6 +1003,8 @@ class Installer
private function updatePackageUrl(PackageInterface $package, $sourceUrl, $sourceType, $sourceReference, $distUrl) private function updatePackageUrl(PackageInterface $package, $sourceUrl, $sourceType, $sourceReference, $distUrl)
{ {
$oldSourceRef = $package->getSourceReference();
if ($package->getSourceUrl() !== $sourceUrl) { if ($package->getSourceUrl() !== $sourceUrl) {
$package->setSourceType($sourceType); $package->setSourceType($sourceType);
$package->setSourceUrl($sourceUrl); $package->setSourceUrl($sourceUrl);
@ -1015,6 +1017,10 @@ class Installer
$package->setDistUrl($distUrl); $package->setDistUrl($distUrl);
$this->updateInstallReferences($package, $sourceReference); $this->updateInstallReferences($package, $sourceReference);
} }
if ($this->updateWhitelist && !$this->isUpdateable($package)) {
$this->updateInstallReferences($package, $oldSourceRef);
}
} }
private function updateInstallReferences(PackageInterface $package, $reference) private function updateInstallReferences(PackageInterface $package, $reference)

View File

@ -1,11 +1,12 @@
--TEST-- --TEST--
Update updates URLs for updated packages if they have changed Update updates URLs for updated packages if they have changed
a/a gets everything updated as it updates to a new ref a/a is dev and gets everything updated as it updates to a new ref
b/b gets everything updated by updating the package URL directly b/b is a tag and gets everything updated by updating the package URL directly
c/c is not whitelisted but still gets its URL updated c/c is a tag and not whitelisted and gets the new URL but keeps its old ref
d/d is dev but with a #ref so it should get URL updated but not the reference d/d is dev but with a #ref so it should get URL updated but not the reference
e/e is newly installed with a #ref so it should get the correct URL but with the #111 ref e/e is dev and newly installed with a #ref so it should get the correct URL but with the #111 ref
e/e is dev but not whitelisted and gets the new URL but keeps its old ref
--COMPOSER-- --COMPOSER--
{ {
"repositories": [ "repositories": [
@ -36,6 +37,11 @@ e/e is newly installed with a #ref so it should get the correct URL but with the
"name": "e/e", "version": "dev-master", "name": "e/e", "version": "dev-master",
"source": { "reference": "2222222222222222222222222222222222222222", "url": "https://github.com/e/newe", "type": "git" }, "source": { "reference": "2222222222222222222222222222222222222222", "url": "https://github.com/e/newe", "type": "git" },
"dist": { "reference": "2222222222222222222222222222222222222222", "url": "https://api.github.com/repos/e/newe/zipball/2222222222222222222222222222222222222222", "type": "zip" } "dist": { "reference": "2222222222222222222222222222222222222222", "url": "https://api.github.com/repos/e/newe/zipball/2222222222222222222222222222222222222222", "type": "zip" }
},
{
"name": "f/f", "version": "dev-master",
"source": { "reference": "2222222222222222222222222222222222222222", "url": "https://github.com/f/newf", "type": "git" },
"dist": { "reference": "2222222222222222222222222222222222222222", "url": "https://api.github.com/repos/f/newf/zipball/2222222222222222222222222222222222222222", "type": "zip" }
} }
] ]
} }
@ -45,7 +51,8 @@ e/e is newly installed with a #ref so it should get the correct URL but with the
"b/b": "2.0.3", "b/b": "2.0.3",
"c/c": "1.0.0", "c/c": "1.0.0",
"d/d": "dev-master#1111111111111111111111111111111111111111", "d/d": "dev-master#1111111111111111111111111111111111111111",
"e/e": "dev-master#1111111111111111111111111111111111111111" "e/e": "dev-master#1111111111111111111111111111111111111111",
"f/f": "dev-master"
} }
} }
--INSTALLED-- --INSTALLED--
@ -69,6 +76,11 @@ e/e is newly installed with a #ref so it should get the correct URL but with the
"name": "d/d", "version": "dev-master", "name": "d/d", "version": "dev-master",
"source": { "reference": "1111111111111111111111111111111111111111", "url": "https://github.com/d/d", "type": "git" }, "source": { "reference": "1111111111111111111111111111111111111111", "url": "https://github.com/d/d", "type": "git" },
"dist": { "reference": "1111111111111111111111111111111111111111", "url": "https://api.github.com/repos/d/d/zipball/1111111111111111111111111111111111111111", "type": "zip" } "dist": { "reference": "1111111111111111111111111111111111111111", "url": "https://api.github.com/repos/d/d/zipball/1111111111111111111111111111111111111111", "type": "zip" }
},
{
"name": "f/f", "version": "dev-master",
"source": { "reference": "1111111111111111111111111111111111111111", "url": "https://github.com/f/f", "type": "git" },
"dist": { "reference": "1111111111111111111111111111111111111111", "url": "https://api.github.com/repos/f/f/zipball/1111111111111111111111111111111111111111", "type": "zip" }
} }
] ]
--EXPECT-LOCK-- --EXPECT-LOCK--
@ -88,8 +100,8 @@ e/e is newly installed with a #ref so it should get the correct URL but with the
}, },
{ {
"name": "c/c", "version": "1.0.0", "name": "c/c", "version": "1.0.0",
"source": { "reference": "2222222222222222222222222222222222222222", "url": "https://github.com/c/newc", "type": "git" }, "source": { "reference": "1111111111111111111111111111111111111111", "url": "https://github.com/c/newc", "type": "git" },
"dist": { "reference": "2222222222222222222222222222222222222222", "url": "https://api.github.com/repos/c/newc/zipball/2222222222222222222222222222222222222222", "type": "zip", "shasum": null }, "dist": { "reference": "1111111111111111111111111111111111111111", "url": "https://api.github.com/repos/c/newc/zipball/1111111111111111111111111111111111111111", "type": "zip", "shasum": null },
"type": "library" "type": "library"
}, },
{ {
@ -103,6 +115,12 @@ e/e is newly installed with a #ref so it should get the correct URL but with the
"source": { "reference": "1111111111111111111111111111111111111111", "url": "https://github.com/e/newe", "type": "git" }, "source": { "reference": "1111111111111111111111111111111111111111", "url": "https://github.com/e/newe", "type": "git" },
"dist": { "reference": "1111111111111111111111111111111111111111", "url": "https://api.github.com/repos/e/newe/zipball/1111111111111111111111111111111111111111", "type": "zip", "shasum": null }, "dist": { "reference": "1111111111111111111111111111111111111111", "url": "https://api.github.com/repos/e/newe/zipball/1111111111111111111111111111111111111111", "type": "zip", "shasum": null },
"type": "library" "type": "library"
},
{
"name": "f/f", "version": "dev-master",
"source": { "reference": "1111111111111111111111111111111111111111", "url": "https://github.com/f/newf", "type": "git" },
"dist": { "reference": "1111111111111111111111111111111111111111", "url": "https://api.github.com/repos/f/newf/zipball/1111111111111111111111111111111111111111", "type": "zip", "shasum": null },
"type": "library"
} }
], ],
"packages-dev": [], "packages-dev": [],
@ -111,7 +129,8 @@ e/e is newly installed with a #ref so it should get the correct URL but with the
"stability-flags": { "stability-flags": {
"a/a": 20, "a/a": 20,
"d/d": 20, "d/d": 20,
"e/e": 20 "e/e": 20,
"f/f": 20
}, },
"prefer-stable": false, "prefer-stable": false,
"prefer-lowest": false, "prefer-lowest": false,