Fix require regression with --fixed, fixes #11247
parent
0d96fd8149
commit
f6f972a699
|
@ -338,7 +338,7 @@ EOT
|
||||||
try {
|
try {
|
||||||
$result = $this->doUpdate($input, $output, $io, $requirements, $requireKey, $removeKey);
|
$result = $this->doUpdate($input, $output, $io, $requirements, $requireKey, $removeKey);
|
||||||
if ($result === 0 && count($requirementsToGuess) > 0) {
|
if ($result === 0 && count($requirementsToGuess) > 0) {
|
||||||
$result = $this->updateRequirementsAfterResolution($requirementsToGuess, $requireKey, $removeKey, $sortPackages, $input->getOption('dry-run'));
|
$result = $this->updateRequirementsAfterResolution($requirementsToGuess, $requireKey, $removeKey, $sortPackages, $input->getOption('dry-run'), $input->getOption('fixed'));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
|
@ -506,7 +506,7 @@ EOT
|
||||||
/**
|
/**
|
||||||
* @param list<string> $requirementsToUpdate
|
* @param list<string> $requirementsToUpdate
|
||||||
*/
|
*/
|
||||||
private function updateRequirementsAfterResolution(array $requirementsToUpdate, string $requireKey, string $removeKey, bool $sortPackages, bool $dryRun): int
|
private function updateRequirementsAfterResolution(array $requirementsToUpdate, string $requireKey, string $removeKey, bool $sortPackages, bool $dryRun, bool $fixed): int
|
||||||
{
|
{
|
||||||
$composer = $this->requireComposer();
|
$composer = $this->requireComposer();
|
||||||
$locker = $composer->getLocker();
|
$locker = $composer->getLocker();
|
||||||
|
@ -523,7 +523,11 @@ EOT
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($fixed) {
|
||||||
|
$requirements[$packageName] = $package->getPrettyVersion();
|
||||||
|
} else {
|
||||||
$requirements[$packageName] = $versionSelector->findRecommendedRequireVersion($package);
|
$requirements[$packageName] = $versionSelector->findRecommendedRequireVersion($package);
|
||||||
|
}
|
||||||
$this->getIO()->writeError(sprintf(
|
$this->getIO()->writeError(sprintf(
|
||||||
'Using version <info>%s</info> for <info>%s</info>',
|
'Using version <info>%s</info> for <info>%s</info>',
|
||||||
$requirements[$packageName],
|
$requirements[$packageName],
|
||||||
|
|
|
@ -236,6 +236,30 @@ Lock file operations: 2 installs, 0 updates, 0 removals
|
||||||
- Locking existing/dep (1.1.0)
|
- Locking existing/dep (1.1.0)
|
||||||
- Locking required/pkg (1.1.0)
|
- Locking required/pkg (1.1.0)
|
||||||
Using version ^1.1 for required/pkg
|
Using version ^1.1 for required/pkg
|
||||||
|
OUTPUT
|
||||||
|
];
|
||||||
|
|
||||||
|
yield 'use exact constraint with --fixed' => [
|
||||||
|
[
|
||||||
|
'type' => 'project',
|
||||||
|
'repositories' => [
|
||||||
|
'packages' => [
|
||||||
|
'type' => 'package',
|
||||||
|
'package' => [
|
||||||
|
['name' => 'required/pkg', 'version' => '1.1.0'],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
['packages' => ['required/pkg'], '--no-install' => true, '--fixed' => true],
|
||||||
|
<<<OUTPUT
|
||||||
|
./composer.json has been updated
|
||||||
|
Running composer update required/pkg
|
||||||
|
Loading composer repositories with package information
|
||||||
|
Updating dependencies
|
||||||
|
Lock file operations: 1 install, 0 updates, 0 removals
|
||||||
|
- Locking required/pkg (1.1.0)
|
||||||
|
Using version 1.1.0 for required/pkg
|
||||||
OUTPUT
|
OUTPUT
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue