Merge pull request #4428 from webfactory/update-source-type-and-ref
Update source type and reference along with URLspull/4060/merge
commit
5736a59fe3
|
@ -1023,7 +1023,15 @@ class Installer
|
||||||
$newPackage = $pool->literalToPackage($matches[0]);
|
$newPackage = $pool->literalToPackage($matches[0]);
|
||||||
|
|
||||||
// update the dist and source URLs
|
// update the dist and source URLs
|
||||||
$package->setSourceUrl($newPackage->getSourceUrl());
|
$sourceUrl = $package->getSourceUrl();
|
||||||
|
$newSourceUrl = $newPackage->getSourceUrl();
|
||||||
|
|
||||||
|
if ($sourceUrl !== $newSourceUrl) {
|
||||||
|
$package->setSourceType($newPackage->getSourceType());
|
||||||
|
$package->setSourceUrl($newSourceUrl);
|
||||||
|
$package->setSourceReference($newPackage->getSourceReference());
|
||||||
|
}
|
||||||
|
|
||||||
// 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 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
|
// but for other urls this is ambiguous and could result in bad outcomes
|
||||||
if (preg_match('{^https?://(?:(?:www\.)?bitbucket\.org|(api\.)?github\.com)/}', $newPackage->getDistUrl())) {
|
if (preg_match('{^https?://(?:(?:www\.)?bitbucket\.org|(api\.)?github\.com)/}', $newPackage->getDistUrl())) {
|
||||||
|
|
|
@ -0,0 +1,57 @@
|
||||||
|
--TEST--
|
||||||
|
Converting from one VCS type to another (including an URL change) should update the lock file.
|
||||||
|
--COMPOSER--
|
||||||
|
{
|
||||||
|
"repositories": [
|
||||||
|
{
|
||||||
|
"type": "package",
|
||||||
|
"package": [
|
||||||
|
{
|
||||||
|
"name": "a/a", "version": "1.0.0",
|
||||||
|
"source": { "reference": "new-git-ref", "type": "git", "url": "new-git-url" }
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"require": {
|
||||||
|
"a/a": "1.0.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
--INSTALLED--
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"name": "a/a", "version": "1.0.0",
|
||||||
|
"source": { "reference": "old-hg-ref", "type": "hg", "url": "old-hg-url" }
|
||||||
|
}
|
||||||
|
]
|
||||||
|
--LOCK--
|
||||||
|
{
|
||||||
|
"packages": [
|
||||||
|
{
|
||||||
|
"name": "a/a", "version": "1.0.0",
|
||||||
|
"source": { "reference": "old-hg-ref", "type": "hg", "url": "old-hg-url" }
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
--RUN--
|
||||||
|
update
|
||||||
|
--EXPECT-LOCK--
|
||||||
|
{
|
||||||
|
"packages": [
|
||||||
|
{
|
||||||
|
"name": "a/a", "version": "1.0.0",
|
||||||
|
"source": { "reference": "new-git-ref", "type": "git", "url": "new-git-url" },
|
||||||
|
"type": "library"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"packages-dev": [],
|
||||||
|
"aliases": [],
|
||||||
|
"minimum-stability": "stable",
|
||||||
|
"stability-flags": [],
|
||||||
|
"prefer-stable": false,
|
||||||
|
"prefer-lowest": false,
|
||||||
|
"platform": [],
|
||||||
|
"platform-dev": []
|
||||||
|
}
|
||||||
|
--EXPECT--
|
||||||
|
|
Loading…
Reference in New Issue