1
0
Fork 0

Merge branch '2.6'

pull/11699/head
Jordi Boggiano 2023-10-26 11:39:41 +02:00
commit cc653161c3
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC
5 changed files with 35 additions and 8 deletions

View File

@ -152,7 +152,23 @@ abstract class BaseDependencyCommand extends BaseCommand
} }
if ($inverted && $input->hasArgument(self::ARGUMENT_CONSTRAINT)) { if ($inverted && $input->hasArgument(self::ARGUMENT_CONSTRAINT)) {
$this->getIO()->writeError('Not finding what you were looking for? Try calling `composer update "'.$input->getArgument(self::ARGUMENT_PACKAGE).':'.$input->getArgument(self::ARGUMENT_CONSTRAINT).'" --dry-run` to get another view on the problem.'); $composerCommand = 'update';
foreach ($composer->getPackage()->getRequires() as $rootRequirement) {
if ($rootRequirement->getTarget() === $needle) {
$composerCommand = 'require';
break;
}
}
foreach ($composer->getPackage()->getDevRequires() as $rootRequirement) {
if ($rootRequirement->getTarget() === $needle) {
$composerCommand = 'require --dev';
break;
}
}
$this->getIO()->writeError('Not finding what you were looking for? Try calling `composer '.$composerCommand.' "'.$needle.':'.$textConstraint.'" --dry-run` to get another view on the problem.');
} }
return 0; return 0;

View File

@ -161,7 +161,9 @@ EOT
$parsedConstraint = $parser->parseConstraints($constraint); $parsedConstraint = $parser->parseConstraints($constraint);
$temporaryConstraints[$package] = $parsedConstraint; $temporaryConstraints[$package] = $parsedConstraint;
if (isset($rootRequirements[$package]) && !Intervals::haveIntersections($parsedConstraint, $rootRequirements[$package]->getConstraint())) { if (isset($rootRequirements[$package]) && !Intervals::haveIntersections($parsedConstraint, $rootRequirements[$package]->getConstraint())) {
throw new \InvalidArgumentException('The temporary constraint "'.$constraint.'" for "'.$package.'" must be a subset of the constraint in your composer.json ('.$rootRequirements[$package]->getPrettyConstraint().')'); $io->writeError('<error>The temporary constraint "'.$constraint.'" for "'.$package.'" must be a subset of the constraint in your composer.json ('.$rootRequirements[$package]->getPrettyConstraint().')</error>');
$io->write('<info>Run `composer require '.$package.'` or `composer require '.$package.':'.$constraint.'` instead to replace the constraint</info>');
return self::FAILURE;
} }
} }

View File

@ -91,7 +91,7 @@ class VcsRepository extends ArrayRepository implements ConfigurableRepositoryInt
'svn' => 'Composer\Repository\Vcs\SvnDriver', 'svn' => 'Composer\Repository\Vcs\SvnDriver',
]; ];
$this->url = Platform::expandPath($repoConfig['url']); $this->url = $repoConfig['url'] = Platform::expandPath($repoConfig['url']);
$this->io = $io; $this->io = $io;
$this->type = $repoConfig['type'] ?? 'vcs'; $this->type = $repoConfig['type'] ?? 'vcs';
$this->isVerbose = $io->isVerbose(); $this->isVerbose = $io->isVerbose();

View File

@ -425,7 +425,7 @@ OUTPUT
<<<OUTPUT <<<OUTPUT
Package "vendor1/package1" could not be found with constraint "3.*", results below will most likely be incomplete. Package "vendor1/package1" could not be found with constraint "3.*", results below will most likely be incomplete.
__root__ - requires vendor1/package1 (1.*) __root__ - requires vendor1/package1 (1.*)
Not finding what you were looking for? Try calling `composer update "vendor1/package1:3.*" --dry-run` to get another view on the problem. Not finding what you were looking for? Try calling `composer require "vendor1/package1:3.*" --dry-run` to get another view on the problem.
OUTPUT OUTPUT
]; ];
@ -434,7 +434,7 @@ OUTPUT
<<<OUTPUT <<<OUTPUT
Package "vendor1/package1" could not be found with constraint "^1.4", results below will most likely be incomplete. Package "vendor1/package1" could not be found with constraint "^1.4", results below will most likely be incomplete.
There is no installed package depending on "vendor1/package1" in versions not matching ^1.4 There is no installed package depending on "vendor1/package1" in versions not matching ^1.4
Not finding what you were looking for? Try calling `composer update "vendor1/package1:^1.4" --dry-run` to get another view on the problem. Not finding what you were looking for? Try calling `composer require "vendor1/package1:^1.4" --dry-run` to get another view on the problem.
OUTPUT OUTPUT
]; ];
@ -442,7 +442,7 @@ OUTPUT
['package' => 'vendor1/package1', 'version' => '^1.3'], ['package' => 'vendor1/package1', 'version' => '^1.3'],
<<<OUTPUT <<<OUTPUT
There is no installed package depending on "vendor1/package1" in versions not matching ^1.3 There is no installed package depending on "vendor1/package1" in versions not matching ^1.3
Not finding what you were looking for? Try calling `composer update "vendor1/package1:^1.3" --dry-run` to get another view on the problem. Not finding what you were looking for? Try calling `composer require "vendor1/package1:^1.3" --dry-run` to get another view on the problem.
OUTPUT OUTPUT
]; ];

View File

@ -89,6 +89,15 @@ Your requirements could not be resolved to an installable set of packages.
Problem 1 Problem 1
- Root composer.json requires root/req 1.* -> satisfiable by root/req[1.0.0]. - Root composer.json requires root/req 1.* -> satisfiable by root/req[1.0.0].
- root/req 1.0.0 requires dep/pkg ^1 -> found dep/pkg[1.0.0, 1.0.1, 1.0.2] but it conflicts with your temporary update constraint (dep/pkg:^2). - root/req 1.0.0 requires dep/pkg ^1 -> found dep/pkg[1.0.0, 1.0.1, 1.0.2] but it conflicts with your temporary update constraint (dep/pkg:^2).
OUTPUT
];
yield 'update with temporary constraint failing resolution on root package' => [
$rootDepAndTransitiveDep,
['--with' => ['root/req:^2']],
<<<OUTPUT
The temporary constraint "^2" for "root/req" must be a subset of the constraint in your composer.json (1.*)
Run `composer require root/req` or `composer require root/req:^2` instead to replace the constraint
OUTPUT OUTPUT
]; ];
} }