1
0
Fork 0

split update --prefer-lowest and --prefer-stable

pull/3450/head
Nicolas Grekas 2014-12-02 09:18:44 +01:00
parent 4a0feb0189
commit 98b254a3ec
4 changed files with 28 additions and 14 deletions

View File

@ -47,7 +47,8 @@ class UpdateCommand extends Command
new InputOption('verbose', 'v|vv|vvv', InputOption::VALUE_NONE, 'Shows more details including new commits pulled in when updating packages.'),
new InputOption('optimize-autoloader', 'o', InputOption::VALUE_NONE, 'Optimize autoloader during autoloader dump.'),
new InputOption('ignore-platform-reqs', null, InputOption::VALUE_NONE, 'Ignore platform requirements (php & ext- packages).'),
new InputOption('prefer-lowest-stable', null, InputOption::VALUE_NONE, 'Forces all packages to their lowest stable version.'),
new InputOption('prefer-stable', null, InputOption::VALUE_NONE, 'Prefer stable versions of dependencies.'),
new InputOption('prefer-lowest', null, InputOption::VALUE_NONE, 'Prefer lowest versions of dependencies.'),
))
->setHelp(<<<EOT
The <info>update</info> command reads the composer.json file from the
@ -122,7 +123,8 @@ EOT
->setUpdateWhitelist($input->getOption('lock') ? array('lock') : $input->getArgument('packages'))
->setWhitelistDependencies($input->getOption('with-dependencies'))
->setIgnorePlatformRequirements($input->getOption('ignore-platform-reqs'))
->setPreferLowestStable($input->getOption('prefer-lowest-stable'))
->setPreferStable($input->getOption('prefer-stable'))
->setPreferLowest($input->getOption('prefer-lowest'))
;
if ($input->getOption('no-plugins')) {

View File

@ -107,7 +107,8 @@ class Installer
protected $update = false;
protected $runScripts = true;
protected $ignorePlatformReqs = false;
protected $preferLowestStable = false;
protected $preferStable = false;
protected $preferLowest = false;
/**
* Array of package names/globs flagged for update
*
@ -702,11 +703,8 @@ class Installer
// old lock file without prefer stable will return null
// so in this case we use the composer.json info
if (null === $preferStable) {
if ($this->preferLowestStable) {
$preferStable = $preferLowest = true;
} else {
$preferStable = $this->package->getPreferStable();
}
$preferStable = $this->preferStable || $this->package->getPreferStable();
$preferLowest = $this->preferLowest;
}
return new DefaultPolicy($preferStable, $preferLowest);
@ -1251,14 +1249,27 @@ class Installer
}
/**
* Should packages be forced to their lowest stable version when updating?
* Should packages be prefered in a stable version when updating?
*
* @param boolean $preferLowestStable
* @param boolean $preferStable
* @return Installer
*/
public function setPreferLowestStable($preferLowestStable = true)
public function setPreferStable($preferStable = true)
{
$this->preferLowestStable = (boolean) $preferLowestStable;
$this->preferStable = (boolean) $preferStable;
return $this;
}
/**
* Should packages be prefered in a lowest version when updating?
*
* @param boolean $preferLowest
* @return Installer
*/
public function setPreferLowest($preferLowest = true)
{
$this->preferLowest = (boolean) $preferLowest;
return $this;
}

View File

@ -34,7 +34,7 @@ Updates packages to their lowest stable version
{ "name": "a/b", "version": "1.0.1" }
]
--RUN--
update --prefer-lowest-stable
update --prefer-lowest --prefer-stable
--EXPECT--
Updating a/a (1.0.0-rc1) to a/a (1.0.1)
Updating a/b (1.0.1) to a/b (1.0.0)

View File

@ -217,7 +217,8 @@ class InstallerTest extends TestCase
->setDryRun($input->getOption('dry-run'))
->setUpdateWhitelist($input->getArgument('packages'))
->setWhitelistDependencies($input->getOption('with-dependencies'))
->setPreferLowestStable($input->getOption('prefer-lowest-stable'))
->setPreferStable($input->getOption('prefer-stable'))
->setPreferLowest($input->getOption('prefer-lowest'))
->setIgnorePlatformRequirements($input->getOption('ignore-platform-reqs'));
return $installer->run();