split update --prefer-lowest and --prefer-stable
parent
4a0feb0189
commit
98b254a3ec
|
@ -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('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('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('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
|
->setHelp(<<<EOT
|
||||||
The <info>update</info> command reads the composer.json file from the
|
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'))
|
->setUpdateWhitelist($input->getOption('lock') ? array('lock') : $input->getArgument('packages'))
|
||||||
->setWhitelistDependencies($input->getOption('with-dependencies'))
|
->setWhitelistDependencies($input->getOption('with-dependencies'))
|
||||||
->setIgnorePlatformRequirements($input->getOption('ignore-platform-reqs'))
|
->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')) {
|
if ($input->getOption('no-plugins')) {
|
||||||
|
|
|
@ -107,7 +107,8 @@ class Installer
|
||||||
protected $update = false;
|
protected $update = false;
|
||||||
protected $runScripts = true;
|
protected $runScripts = true;
|
||||||
protected $ignorePlatformReqs = false;
|
protected $ignorePlatformReqs = false;
|
||||||
protected $preferLowestStable = false;
|
protected $preferStable = false;
|
||||||
|
protected $preferLowest = false;
|
||||||
/**
|
/**
|
||||||
* Array of package names/globs flagged for update
|
* Array of package names/globs flagged for update
|
||||||
*
|
*
|
||||||
|
@ -702,11 +703,8 @@ class Installer
|
||||||
// old lock file without prefer stable will return null
|
// old lock file without prefer stable 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) {
|
||||||
if ($this->preferLowestStable) {
|
$preferStable = $this->preferStable || $this->package->getPreferStable();
|
||||||
$preferStable = $preferLowest = true;
|
$preferLowest = $this->preferLowest;
|
||||||
} else {
|
|
||||||
$preferStable = $this->package->getPreferStable();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return new DefaultPolicy($preferStable, $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
|
* @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;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ Updates packages to their lowest stable version
|
||||||
{ "name": "a/b", "version": "1.0.1" }
|
{ "name": "a/b", "version": "1.0.1" }
|
||||||
]
|
]
|
||||||
--RUN--
|
--RUN--
|
||||||
update --prefer-lowest-stable
|
update --prefer-lowest --prefer-stable
|
||||||
--EXPECT--
|
--EXPECT--
|
||||||
Updating a/a (1.0.0-rc1) to a/a (1.0.1)
|
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)
|
Updating a/b (1.0.1) to a/b (1.0.0)
|
||||||
|
|
|
@ -217,7 +217,8 @@ class InstallerTest extends TestCase
|
||||||
->setDryRun($input->getOption('dry-run'))
|
->setDryRun($input->getOption('dry-run'))
|
||||||
->setUpdateWhitelist($input->getArgument('packages'))
|
->setUpdateWhitelist($input->getArgument('packages'))
|
||||||
->setWhitelistDependencies($input->getOption('with-dependencies'))
|
->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'));
|
->setIgnorePlatformRequirements($input->getOption('ignore-platform-reqs'));
|
||||||
|
|
||||||
return $installer->run();
|
return $installer->run();
|
||||||
|
|
Loading…
Reference in New Issue