Fix parsing "branch-version"
parent
fec3c6a4e9
commit
4feed8b85c
|
@ -82,7 +82,7 @@ class RootPackageLoader extends ArrayLoader
|
|||
$commit = null;
|
||||
|
||||
if (isset($config['extra']['branch-version'])) {
|
||||
$config['version'] = preg_replace('{(\.x)?(-dev)?$}', '.x-dev', $config['extra']['branch-version']);
|
||||
$config['version'] = preg_replace('{(\.x)?(-dev)?$}', '', $config['extra']['branch-version']).'.x-dev';
|
||||
} elseif (getenv('COMPOSER_ROOT_VERSION')) {
|
||||
// override with env var if available
|
||||
$config['version'] = getenv('COMPOSER_ROOT_VERSION');
|
||||
|
|
|
@ -167,7 +167,7 @@ class PathRepository extends ArrayRepository implements ConfigurableRepositoryIn
|
|||
|
||||
// use the branch-version as the package version if available
|
||||
if (!isset($package['version']) && isset($package['extra']['branch-version'])) {
|
||||
$package['version'] = preg_replace('{(\.x)?(-dev)?$}', '.x-dev', $package['extra']['branch-version']);
|
||||
$package['version'] = preg_replace('{(\.x)?(-dev)?$}', '', $package['extra']['branch-version']).'.x-dev';
|
||||
}
|
||||
|
||||
// carry over the root package version if this path repo is in the same git repository as root package
|
||||
|
|
|
@ -202,14 +202,27 @@ class RootPackageLoaderTest extends TestCase
|
|||
$this->assertEquals("dev-latest-production", $package->getPrettyVersion());
|
||||
}
|
||||
|
||||
public function testLoadExtraBranchVersion()
|
||||
/**
|
||||
* @dataProvider provideExtraBranchVersion
|
||||
*/
|
||||
public function testLoadExtraBranchVersion($branchVersion)
|
||||
{
|
||||
$package = $this->loadPackage(array(
|
||||
'extra' => array(
|
||||
'branch-version' => '1.2',
|
||||
'branch-version' => $branchVersion,
|
||||
),
|
||||
));
|
||||
|
||||
$this->assertEquals('1.2.x-dev', $package->getPrettyVersion());
|
||||
}
|
||||
|
||||
public function provideExtraBranchVersion()
|
||||
{
|
||||
return array(
|
||||
array('1.2'),
|
||||
array('1.2.x'),
|
||||
array('1.2-dev'),
|
||||
array('1.2.x-dev'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue