pull/6804/merge
parent
40f4f6bf86
commit
3cf31da414
|
@ -68,22 +68,25 @@ class RootPackageLoader extends ArrayLoader
|
||||||
}
|
}
|
||||||
$autoVersioned = false;
|
$autoVersioned = false;
|
||||||
if (!isset($config['version'])) {
|
if (!isset($config['version'])) {
|
||||||
|
$commit = null;
|
||||||
|
|
||||||
// override with env var if available
|
// override with env var if available
|
||||||
if (getenv('COMPOSER_ROOT_VERSION')) {
|
if (getenv('COMPOSER_ROOT_VERSION')) {
|
||||||
$version = getenv('COMPOSER_ROOT_VERSION');
|
$config['version'] = getenv('COMPOSER_ROOT_VERSION');
|
||||||
$commit = null;
|
|
||||||
} else {
|
} else {
|
||||||
$versionData = $this->versionGuesser->guessVersion($config, $cwd ?: getcwd());
|
$versionData = $this->versionGuesser->guessVersion($config, $cwd ?: getcwd());
|
||||||
$version = $versionData['version'];
|
if ($versionData) {
|
||||||
$commit = $versionData['commit'];
|
$config['version'] = $versionData['pretty_version'];
|
||||||
|
$config['version_normalized'] = $versionData['version'];
|
||||||
|
$commit = $versionData['commit'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$version) {
|
if (!isset($config['version'])) {
|
||||||
$version = '1.0.0';
|
$config['version'] = '1.0.0';
|
||||||
$autoVersioned = true;
|
$autoVersioned = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$config['version'] = $version;
|
|
||||||
if ($commit) {
|
if ($commit) {
|
||||||
$config['source'] = array(
|
$config['source'] = array(
|
||||||
'type' => '',
|
'type' => '',
|
||||||
|
|
|
@ -17,6 +17,7 @@ use Composer\Package\Loader\RootPackageLoader;
|
||||||
use Composer\Package\BasePackage;
|
use Composer\Package\BasePackage;
|
||||||
use Composer\Package\Version\VersionGuesser;
|
use Composer\Package\Version\VersionGuesser;
|
||||||
use Composer\Semver\VersionParser;
|
use Composer\Semver\VersionParser;
|
||||||
|
use Prophecy\Argument;
|
||||||
|
|
||||||
class RootPackageLoaderTest extends \PHPUnit_Framework_TestCase
|
class RootPackageLoaderTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
|
@ -91,6 +92,26 @@ class RootPackageLoaderTest extends \PHPUnit_Framework_TestCase
|
||||||
$this->assertEquals("No version set (parsed as 1.0.0)", $package->getPrettyVersion());
|
$this->assertEquals("No version set (parsed as 1.0.0)", $package->getPrettyVersion());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testPrettyVersionForRootPackageInVersionBranch()
|
||||||
|
{
|
||||||
|
// see #6845
|
||||||
|
$manager = $this->prophesize('\\Composer\\Repository\\RepositoryManager');
|
||||||
|
$versionGuesser = $this->prophesize('\\Composer\\Package\\Version\\VersionGuesser');
|
||||||
|
$versionGuesser->guessVersion(Argument::cetera())
|
||||||
|
->willReturn(array(
|
||||||
|
'name' => 'A',
|
||||||
|
'version' => '3.0.9999999.9999999-dev',
|
||||||
|
'pretty_version' => '3.0-dev',
|
||||||
|
'commit' => 'aabbccddee',
|
||||||
|
));
|
||||||
|
$config = new Config;
|
||||||
|
$config->merge(array('repositories' => array('packagist' => false)));
|
||||||
|
$loader = new RootPackageLoader($manager->reveal(), $config, null, $versionGuesser->reveal());
|
||||||
|
$package = $loader->load(array());
|
||||||
|
|
||||||
|
$this->assertEquals('3.0-dev', $package->getPrettyVersion());
|
||||||
|
}
|
||||||
|
|
||||||
public function testFeatureBranchPrettyVersion()
|
public function testFeatureBranchPrettyVersion()
|
||||||
{
|
{
|
||||||
if (!function_exists('proc_open')) {
|
if (!function_exists('proc_open')) {
|
||||||
|
|
Loading…
Reference in New Issue