Skip to content
Snippets Groups Projects
Commit 607dcd07 authored by Chris Wells's avatar Chris Wells Committed by Adam G-H
Browse files

Issue #3349966 by phenaproxima, chrisfromredfin, tedbow, rkoller:...

Issue #3349966 by phenaproxima, chrisfromredfin, tedbow, rkoller: ComposerInspector should account for the way `composer show` displays versions of packages installed from dev snapshots, to avoid angering Semver::satisfies()
parent 93df6d43
No related branches found
No related tags found
2 merge requests!989Issue #3356804 by phenaproxima: Flag a warning during status check if the...,!799Issue #3349966: Dev versions of plugins anger Semver::satisfies()
......@@ -315,6 +315,15 @@ class ComposerInspector implements LoggerAwareInterface {
foreach ($packages_data as $name => $package) {
$path = $package['path'];
// For packages installed as dev snapshots from certain version control
// systems, `composer show` displays the version like `1.0.x-dev 0a1b2c`,
// which will cause an exception if we try to parse it as a legitimate
// semantic version. Since we don't need the abbreviated commit hash, just
// remove it.
if (str_contains($package['version'], '-dev ')) {
$packages_data[$name]['version'] = explode(' ', $package['version'], 2)[0];
}
// We expect Composer to report that metapackages' install paths are the
// same as the working directory, in which case InstalledPackage::$path
// should be NULL. For all other package types, we consider it invalid
......
......@@ -417,6 +417,36 @@ class ComposerInspectorTest extends PackageManagerKernelTestBase {
$this->assertSame($is_metapackage, is_null($list['test/package']->path));
}
/**
* Tests that the commit hash of a dev snapshot package is ignored.
*/
public function testPackageDevSnapshotCommitHashIsRemoved(): void {
$inspector = new class (
$this->container->get(ComposerProcessRunnerInterface::class),
$this->container->get(ComposerIsAvailableInterface::class),
$this->container->get(PathFactoryInterface::class),
) extends ComposerInspector {
/**
* {@inheritdoc}
*/
protected function show(string $working_dir): array {
return [
'test/package' => [
'name' => 'test/package',
'path' => __DIR__,
'version' => '1.0.x-dev 0a1b2c3d',
],
];
}
};
$project_root = $this->container->get(PathLocator::class)
->getProjectRoot();
$list = $inspector->getInstalledPackagesList($project_root);
$this->assertSame('1.0.x-dev', $list['test/package']->version);
}
/**
* Data provider for ::testAllowedPlugins().
*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment