Skip to content

Copy extra.symfony.require when unpacking #443

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Command/RequireCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$op->addPackage($package['name'], $package['version'] ?? '', $input->getOption('dev'));
}

$unpacker = new Unpacker($this->getComposer());
$unpacker = new Unpacker($this->getComposer(), $this->resolver);
$result = $unpacker->unpack($op);
$io = $this->getIO();
foreach ($result->getUnpacked() as $pkg) {
Expand Down
2 changes: 1 addition & 1 deletion src/Command/UnpackCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$op->addPackage($pkg->getName(), $pkg->getVersion(), $dev);
}

$unpacker = new Unpacker($composer);
$unpacker = new Unpacker($composer, $this->resolver);
$result = $unpacker->unpack($op);

// remove the packages themselves
Expand Down
4 changes: 2 additions & 2 deletions src/PackageResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public function resolve(array $arguments = [], bool $isRequire = false): array
return array_unique($requires);
}

private function parseVersion(string $package, string $version, bool $isRequire): string
public function parseVersion(string $package, string $version, bool $isRequire): string
{
if (0 !== strpos($package, 'symfony/')) {
return $version ? ':'.$version : '';
Expand All @@ -94,7 +94,7 @@ private function parseVersion(string $package, string $version, bool $isRequire)
return $version ? ':'.$version : '';
}

if (!$version) {
if (!$version || '*' === $version) {
try {
$config = @json_decode(file_get_contents(Factory::getComposerFile()), true);
} finally {
Expand Down
9 changes: 7 additions & 2 deletions src/Unpacker.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@
class Unpacker
{
private $composer;
private $resolver;

public function __construct(Composer $composer)
public function __construct(Composer $composer, PackageResolver $resolver)
{
$this->composer = $composer;
$this->resolver = $resolver;
}

public function unpack(Operation $op): Result
Expand Down Expand Up @@ -53,7 +55,10 @@ public function unpack(Operation $op): Result
continue;
}

if (!$manipulator->addLink($package['dev'] ? 'require-dev' : 'require', $link->getTarget(), $link->getPrettyConstraint(), $op->shouldSort())) {
$constraint = $link->getPrettyConstraint();
$constraint = substr($this->resolver->parseVersion($link->getTarget(), $constraint, !$package['dev']), 1) ?: $constraint;

if (!$manipulator->addLink($package['dev'] ? 'require-dev' : 'require', $link->getTarget(), $constraint, $op->shouldSort())) {
throw new \RuntimeException(sprintf('Unable to unpack package "%s".', $link->getTarget()));
}
}
Expand Down