pull/6804/merge
parent
40f4f6bf86
commit
3cf31da414
|
@ -68,22 +68,25 @@ class RootPackageLoader extends ArrayLoader
|
|||
}
|
||||
$autoVersioned = false;
|
||||
if (!isset($config['version'])) {
|
||||
$commit = null;
|
||||
|
||||
// override with env var if available
|
||||
if (getenv('COMPOSER_ROOT_VERSION')) {
|
||||
$version = getenv('COMPOSER_ROOT_VERSION');
|
||||
$commit = null;
|
||||
$config['version'] = getenv('COMPOSER_ROOT_VERSION');
|
||||
} else {
|
||||
$versionData = $this->versionGuesser->guessVersion($config, $cwd ?: getcwd());
|
||||
$version = $versionData['version'];
|
||||
$commit = $versionData['commit'];
|
||||
if ($versionData) {
|
||||
$config['version'] = $versionData['pretty_version'];
|
||||
$config['version_normalized'] = $versionData['version'];
|
||||
$commit = $versionData['commit'];
|
||||
}
|
||||
}
|
||||
|
||||
if (!$version) {
|
||||
$version = '1.0.0';
|
||||
if (!isset($config['version'])) {
|
||||
$config['version'] = '1.0.0';
|
||||
$autoVersioned = true;
|
||||
}
|
||||
|
||||
$config['version'] = $version;
|
||||
if ($commit) {
|
||||
$config['source'] = array(
|
||||
'type' => '',
|
||||
|
|
|
@ -17,6 +17,7 @@ use Composer\Package\Loader\RootPackageLoader;
|
|||
use Composer\Package\BasePackage;
|
||||
use Composer\Package\Version\VersionGuesser;
|
||||
use Composer\Semver\VersionParser;
|
||||
use Prophecy\Argument;
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
if (!function_exists('proc_open')) {
|
||||
|
|
Loading…
Reference in New Issue