Revert converting `1.0.0` to `^1.0`.
parent
9fb2d4f2d6
commit
12c833864c
|
@ -32,13 +32,7 @@ requirements:
|
|||
to define which Plugin API versions your plugin is compatible with.
|
||||
|
||||
The required version of the `composer-plugin-api` follows the same [rules][7]
|
||||
as a normal package's, except for the `1.0`, `1.0.0` and `1.0.0.0` _exact_
|
||||
values. In only these three cases, Composer will assume your plugin
|
||||
actually meant `^1.0` instead. This was introduced to maintain BC with
|
||||
the old style of declaring the Plugin API version.
|
||||
|
||||
In other words, `"require": { "composer-plugin-api": "1.0.0" }` means
|
||||
`"require": { "composer-plugin-api": "^1.0" }`.
|
||||
as a normal package's.
|
||||
|
||||
The current composer plugin API version is 1.0.0.
|
||||
|
||||
|
|
|
@ -228,27 +228,12 @@ class VersionParser
|
|||
$parsedConstraint = $this->parseConstraints($constraint);
|
||||
}
|
||||
|
||||
// if the required Plugin API version is exactly "1.0.0", convert it to "^1.0", to keep BC
|
||||
if ('composer-plugin-api' === strtolower($target) && $this->isOldStylePluginApiVersion($constraint)) {
|
||||
$parsedConstraint = $this->parseConstraints('^1.0');
|
||||
}
|
||||
|
||||
$res[strtolower($target)] = new Link($source, $target, $parsedConstraint, $description, $constraint);
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $requiredPluginApiVersion
|
||||
* @return bool
|
||||
*/
|
||||
private function isOldStylePluginApiVersion($requiredPluginApiVersion)
|
||||
{
|
||||
// catch "1.0", "1.0.0", "1.0.0.0" etc.
|
||||
return (bool) preg_match('#^1(\.0)++$#', trim($requiredPluginApiVersion));
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses as constraint string into LinkConstraint objects
|
||||
*
|
||||
|
|
|
@ -515,18 +515,12 @@ class VersionParserTest extends \PHPUnit_Framework_TestCase
|
|||
);
|
||||
}
|
||||
|
||||
public function oldStylePluginApiVersions()
|
||||
public function pluginApiVersions()
|
||||
{
|
||||
return array(
|
||||
array('1.0'),
|
||||
array('1.0.0'),
|
||||
array('1.0.0.0'),
|
||||
);
|
||||
}
|
||||
|
||||
public function newStylePluginApiVersions()
|
||||
{
|
||||
return array(
|
||||
array('1'),
|
||||
array('=1.0.0'),
|
||||
array('==1.0'),
|
||||
|
@ -543,23 +537,9 @@ class VersionParserTest extends \PHPUnit_Framework_TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* @dataProvider oldStylePluginApiVersions
|
||||
* @dataProvider pluginApiVersions
|
||||
*/
|
||||
public function testOldStylePluginApiVersionGetsConvertedIntoAnotherConstraintToKeepBc($apiVersion)
|
||||
{
|
||||
$parser = new VersionParser;
|
||||
|
||||
/** @var Link[] $links */
|
||||
$links = $parser->parseLinks('Plugin', '9.9.9', '', array('composer-plugin-api' => $apiVersion));
|
||||
|
||||
$this->assertArrayHasKey('composer-plugin-api', $links);
|
||||
$this->assertSame('^1.0', $links['composer-plugin-api']->getConstraint()->getPrettyString());
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider newStylePluginApiVersions
|
||||
*/
|
||||
public function testNewStylePluginApiVersionAreKeptAsDeclared($apiVersion)
|
||||
public function testPluginApiVersionAreKeptAsDeclared($apiVersion)
|
||||
{
|
||||
$parser = new VersionParser;
|
||||
|
||||
|
|
|
@ -249,21 +249,21 @@ class PluginInstallerTest extends TestCase
|
|||
$this->pm->loadInstalledPlugins();
|
||||
}
|
||||
|
||||
public function testOldPluginVersionStyleWorksWithAPIUntil199()
|
||||
public function testExactPluginVersionStyleAreRegisteredCorrectly()
|
||||
{
|
||||
$pluginsWithOldStyleAPIVersions = array(
|
||||
$pluginsWithFixedAPIVersions = array(
|
||||
$this->packages[0],
|
||||
$this->packages[1],
|
||||
$this->packages[2],
|
||||
);
|
||||
|
||||
$this->setPluginApiVersionWithPlugins('1.0.0', $pluginsWithOldStyleAPIVersions);
|
||||
$this->setPluginApiVersionWithPlugins('1.0.0', $pluginsWithFixedAPIVersions);
|
||||
$this->assertCount(3, $this->pm->getPlugins());
|
||||
|
||||
$this->setPluginApiVersionWithPlugins('1.9.9', $pluginsWithOldStyleAPIVersions);
|
||||
$this->assertCount(3, $this->pm->getPlugins());
|
||||
$this->setPluginApiVersionWithPlugins('1.0.1', $pluginsWithFixedAPIVersions);
|
||||
$this->assertCount(0, $this->pm->getPlugins());
|
||||
|
||||
$this->setPluginApiVersionWithPlugins('2.0.0-dev', $pluginsWithOldStyleAPIVersions);
|
||||
$this->setPluginApiVersionWithPlugins('2.0.0-dev', $pluginsWithFixedAPIVersions);
|
||||
$this->assertCount(0, $this->pm->getPlugins());
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue