Persist prefer-lowest in composer.lock
parent
98b254a3ec
commit
e821ac2772
|
@ -140,7 +140,9 @@ php composer.phar update vendor/*
|
||||||
* **--lock:** Only updates the lock file hash to suppress warning about the
|
* **--lock:** Only updates the lock file hash to suppress warning about the
|
||||||
lock file being out of date.
|
lock file being out of date.
|
||||||
* **--with-dependencies** Add also all dependencies of whitelisted packages to the whitelist.
|
* **--with-dependencies** Add also all dependencies of whitelisted packages to the whitelist.
|
||||||
So all packages with their dependencies are updated recursively.
|
* **--prefer-stable:** Prefer stable versions of dependencies.
|
||||||
|
* **--prefer-lowest:** Prefer lowest versions of dependencies. Useful for testing minimal
|
||||||
|
versions of requirements, generally used with `--prefer-stable`.
|
||||||
|
|
||||||
## require
|
## require
|
||||||
|
|
||||||
|
|
|
@ -309,7 +309,8 @@ class Installer
|
||||||
$aliases,
|
$aliases,
|
||||||
$this->package->getMinimumStability(),
|
$this->package->getMinimumStability(),
|
||||||
$this->package->getStabilityFlags(),
|
$this->package->getStabilityFlags(),
|
||||||
$this->package->getPreferStable()
|
$this->preferStable || $this->package->getPreferStable(),
|
||||||
|
$this->preferLowest
|
||||||
);
|
);
|
||||||
if ($updatedLock) {
|
if ($updatedLock) {
|
||||||
$this->io->write('<info>Writing lock file</info>');
|
$this->io->write('<info>Writing lock file</info>');
|
||||||
|
@ -695,15 +696,18 @@ class Installer
|
||||||
|
|
||||||
private function createPolicy()
|
private function createPolicy()
|
||||||
{
|
{
|
||||||
$preferLowest = false;
|
|
||||||
$preferStable = null;
|
$preferStable = null;
|
||||||
|
$preferLowest = null;
|
||||||
if (!$this->update && $this->locker->isLocked()) {
|
if (!$this->update && $this->locker->isLocked()) {
|
||||||
$preferStable = $this->locker->getPreferStable();
|
$preferStable = $this->locker->getPreferStable();
|
||||||
|
$preferLowest = $this->locker->getPreferLowest();
|
||||||
}
|
}
|
||||||
// old lock file without prefer stable will return null
|
// old lock file without prefer stable/lowest will return null
|
||||||
// so in this case we use the composer.json info
|
// so in this case we use the composer.json info
|
||||||
if (null === $preferStable) {
|
if (null === $preferStable) {
|
||||||
$preferStable = $this->preferStable || $this->package->getPreferStable();
|
$preferStable = $this->preferStable || $this->package->getPreferStable();
|
||||||
|
}
|
||||||
|
if (null === $preferLowest) {
|
||||||
$preferLowest = $this->preferLowest;
|
$preferLowest = $this->preferLowest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -182,6 +182,15 @@ class Locker
|
||||||
return isset($lockData['prefer-stable']) ? $lockData['prefer-stable'] : null;
|
return isset($lockData['prefer-stable']) ? $lockData['prefer-stable'] : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getPreferLowest()
|
||||||
|
{
|
||||||
|
$lockData = $this->getLockData();
|
||||||
|
|
||||||
|
// return null if not set to allow caller logic to choose the
|
||||||
|
// right behavior since old lock files have no prefer-lowest
|
||||||
|
return isset($lockData['prefer-lowest']) ? $lockData['prefer-lowest'] : null;
|
||||||
|
}
|
||||||
|
|
||||||
public function getAliases()
|
public function getAliases()
|
||||||
{
|
{
|
||||||
$lockData = $this->getLockData();
|
$lockData = $this->getLockData();
|
||||||
|
@ -213,10 +222,11 @@ class Locker
|
||||||
* @param string $minimumStability
|
* @param string $minimumStability
|
||||||
* @param array $stabilityFlags
|
* @param array $stabilityFlags
|
||||||
* @param bool $preferStable
|
* @param bool $preferStable
|
||||||
|
* @param bool $preferLowest
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function setLockData(array $packages, $devPackages, array $platformReqs, $platformDevReqs, array $aliases, $minimumStability, array $stabilityFlags, $preferStable)
|
public function setLockData(array $packages, $devPackages, array $platformReqs, $platformDevReqs, array $aliases, $minimumStability, array $stabilityFlags, $preferStable, $preferLowest)
|
||||||
{
|
{
|
||||||
$lock = array(
|
$lock = array(
|
||||||
'_readme' => array('This file locks the dependencies of your project to a known state',
|
'_readme' => array('This file locks the dependencies of your project to a known state',
|
||||||
|
@ -229,6 +239,7 @@ class Locker
|
||||||
'minimum-stability' => $minimumStability,
|
'minimum-stability' => $minimumStability,
|
||||||
'stability-flags' => $stabilityFlags,
|
'stability-flags' => $stabilityFlags,
|
||||||
'prefer-stable' => $preferStable,
|
'prefer-stable' => $preferStable,
|
||||||
|
'prefer-lowest' => $preferLowest,
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach ($aliases as $package => $versions) {
|
foreach ($aliases as $package => $versions) {
|
||||||
|
|
|
@ -48,6 +48,7 @@ install --prefer-dist
|
||||||
"a/a": 20
|
"a/a": 20
|
||||||
},
|
},
|
||||||
"prefer-stable": false,
|
"prefer-stable": false,
|
||||||
|
"prefer-lowest": false,
|
||||||
"platform": [],
|
"platform": [],
|
||||||
"platform-dev": []
|
"platform-dev": []
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,8 @@ Requirements from the composer file are not installed if the lock file is presen
|
||||||
"aliases": [],
|
"aliases": [],
|
||||||
"minimum-stability": "stable",
|
"minimum-stability": "stable",
|
||||||
"stability-flags": [],
|
"stability-flags": [],
|
||||||
"prefer-stable": false
|
"prefer-stable": false,
|
||||||
|
"prefer-lowest": false
|
||||||
}
|
}
|
||||||
--RUN--
|
--RUN--
|
||||||
install
|
install
|
||||||
|
|
|
@ -33,7 +33,8 @@ Installing an old alias that doesn't exist anymore from a lock is possible
|
||||||
"aliases": [],
|
"aliases": [],
|
||||||
"minimum-stability": "dev",
|
"minimum-stability": "dev",
|
||||||
"stability-flags": [],
|
"stability-flags": [],
|
||||||
"prefer-stable": false
|
"prefer-stable": false,
|
||||||
|
"prefer-lowest": false
|
||||||
}
|
}
|
||||||
--RUN--
|
--RUN--
|
||||||
install
|
install
|
||||||
|
|
|
@ -36,6 +36,7 @@ Partial update from lock file should apply lock file and downgrade unstable pack
|
||||||
"b/unstable": 15
|
"b/unstable": 15
|
||||||
},
|
},
|
||||||
"prefer-stable": false,
|
"prefer-stable": false,
|
||||||
|
"prefer-lowest": false,
|
||||||
"platform": [],
|
"platform": [],
|
||||||
"platform-dev": []
|
"platform-dev": []
|
||||||
}
|
}
|
||||||
|
@ -59,6 +60,7 @@ update c/uptodate
|
||||||
"minimum-stability": "stable",
|
"minimum-stability": "stable",
|
||||||
"stability-flags": [],
|
"stability-flags": [],
|
||||||
"prefer-stable": false,
|
"prefer-stable": false,
|
||||||
|
"prefer-lowest": false,
|
||||||
"platform": [],
|
"platform": [],
|
||||||
"platform-dev": []
|
"platform-dev": []
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,7 @@ Partial update from lock file should update everything to the state of the lock,
|
||||||
"b/unstable": 15
|
"b/unstable": 15
|
||||||
},
|
},
|
||||||
"prefer-stable": false,
|
"prefer-stable": false,
|
||||||
|
"prefer-lowest": false,
|
||||||
"platform": [],
|
"platform": [],
|
||||||
"platform-dev": []
|
"platform-dev": []
|
||||||
}
|
}
|
||||||
|
@ -59,6 +60,7 @@ update b/unstable
|
||||||
"minimum-stability": "stable",
|
"minimum-stability": "stable",
|
||||||
"stability-flags": [],
|
"stability-flags": [],
|
||||||
"prefer-stable": false,
|
"prefer-stable": false,
|
||||||
|
"prefer-lowest": false,
|
||||||
"platform": [],
|
"platform": [],
|
||||||
"platform-dev": []
|
"platform-dev": []
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,6 +43,7 @@ update b/unstable
|
||||||
"minimum-stability": "stable",
|
"minimum-stability": "stable",
|
||||||
"stability-flags": [],
|
"stability-flags": [],
|
||||||
"prefer-stable": false,
|
"prefer-stable": false,
|
||||||
|
"prefer-lowest": false,
|
||||||
"platform": [],
|
"platform": [],
|
||||||
"platform-dev": []
|
"platform-dev": []
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,8 @@ Update aliased package does not mess up the lock file
|
||||||
"aliases": [],
|
"aliases": [],
|
||||||
"minimum-stability": "dev",
|
"minimum-stability": "dev",
|
||||||
"stability-flags": [],
|
"stability-flags": [],
|
||||||
"prefer-stable": false
|
"prefer-stable": false,
|
||||||
|
"prefer-lowest": false
|
||||||
}
|
}
|
||||||
--INSTALLED--
|
--INSTALLED--
|
||||||
[
|
[
|
||||||
|
@ -66,6 +67,7 @@ update
|
||||||
"minimum-stability": "dev",
|
"minimum-stability": "dev",
|
||||||
"stability-flags": [],
|
"stability-flags": [],
|
||||||
"prefer-stable": false,
|
"prefer-stable": false,
|
||||||
|
"prefer-lowest": false,
|
||||||
"platform": [],
|
"platform": [],
|
||||||
"platform-dev": []
|
"platform-dev": []
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,8 @@ Limited update takes rules from lock if available, and not from the installed re
|
||||||
"aliases": [],
|
"aliases": [],
|
||||||
"minimum-stability": "stable",
|
"minimum-stability": "stable",
|
||||||
"stability-flags": [],
|
"stability-flags": [],
|
||||||
"prefer-stable": false
|
"prefer-stable": false,
|
||||||
|
"prefer-lowest": false
|
||||||
}
|
}
|
||||||
--INSTALLED--
|
--INSTALLED--
|
||||||
[
|
[
|
||||||
|
|
|
@ -20,7 +20,8 @@ Installing locked dev packages should remove old dependencies
|
||||||
"aliases": [],
|
"aliases": [],
|
||||||
"minimum-stability": "dev",
|
"minimum-stability": "dev",
|
||||||
"stability-flags": [],
|
"stability-flags": [],
|
||||||
"prefer-stable": false
|
"prefer-stable": false,
|
||||||
|
"prefer-lowest": false
|
||||||
}
|
}
|
||||||
--INSTALLED--
|
--INSTALLED--
|
||||||
[
|
[
|
||||||
|
|
|
@ -32,7 +32,8 @@ Updating a dev package for new reference updates the url and reference
|
||||||
"aliases": [],
|
"aliases": [],
|
||||||
"minimum-stability": "dev",
|
"minimum-stability": "dev",
|
||||||
"stability-flags": {"a/a":20},
|
"stability-flags": {"a/a":20},
|
||||||
"prefer-stable": false
|
"prefer-stable": false,
|
||||||
|
"prefer-lowest": false
|
||||||
}
|
}
|
||||||
--INSTALLED--
|
--INSTALLED--
|
||||||
[
|
[
|
||||||
|
@ -59,6 +60,7 @@ update
|
||||||
"minimum-stability": "dev",
|
"minimum-stability": "dev",
|
||||||
"stability-flags": {"a/a":20},
|
"stability-flags": {"a/a":20},
|
||||||
"prefer-stable": false,
|
"prefer-stable": false,
|
||||||
|
"prefer-lowest": false,
|
||||||
"platform": [],
|
"platform": [],
|
||||||
"platform-dev": []
|
"platform-dev": []
|
||||||
}
|
}
|
||||||
|
|
|
@ -135,9 +135,10 @@ class LockerTest extends \PHPUnit_Framework_TestCase
|
||||||
'platform' => array(),
|
'platform' => array(),
|
||||||
'platform-dev' => array(),
|
'platform-dev' => array(),
|
||||||
'prefer-stable' => false,
|
'prefer-stable' => false,
|
||||||
|
'prefer-lowest' => false,
|
||||||
));
|
));
|
||||||
|
|
||||||
$locker->setLockData(array($package1, $package2), array(), array(), array(), array(), 'dev', array(), false);
|
$locker->setLockData(array($package1, $package2), array(), array(), array(), array(), 'dev', array(), false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testLockBadPackages()
|
public function testLockBadPackages()
|
||||||
|
@ -156,7 +157,7 @@ class LockerTest extends \PHPUnit_Framework_TestCase
|
||||||
|
|
||||||
$this->setExpectedException('LogicException');
|
$this->setExpectedException('LogicException');
|
||||||
|
|
||||||
$locker->setLockData(array($package1), array(), array(), array(), array(), 'dev', array(), false);
|
$locker->setLockData(array($package1), array(), array(), array(), array(), 'dev', array(), false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testIsFresh()
|
public function testIsFresh()
|
||||||
|
|
Loading…
Reference in New Issue