Merge branch '1.10'

main
Jordi Boggiano 4 years ago
commit bafdf9f705
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC

@ -69,6 +69,13 @@
* Fixed suggest output being very spammy, it now is only one line long and shows more rarely * Fixed suggest output being very spammy, it now is only one line long and shows more rarely
* Fixed conflict rules like e.g. >=5 from matching dev-master, as it is not normalized to 9999999-dev internally anymore * Fixed conflict rules like e.g. >=5 from matching dev-master, as it is not normalized to 9999999-dev internally anymore
### [1.10.14] 2020-10-13
* Fixed version guesser to look at remote branches as well as local ones
* Fixed path repositories version guessing to handle edge cases where version is different from the VCS-guessed version
* Fixed COMPOSER env var causing issues when combined with the `global ` command
* Fixed a few issues dealing with PHP without openssl extension (not recommended at all but sometimes needed for testing)
### [1.10.13] 2020-09-09 ### [1.10.13] 2020-09-09
* Fixed regressions with old version validation * Fixed regressions with old version validation
@ -969,6 +976,7 @@
[2.0.0-alpha3]: https://github.com/composer/composer/compare/2.0.0-alpha2...2.0.0-alpha3 [2.0.0-alpha3]: https://github.com/composer/composer/compare/2.0.0-alpha2...2.0.0-alpha3
[2.0.0-alpha2]: https://github.com/composer/composer/compare/2.0.0-alpha1...2.0.0-alpha2 [2.0.0-alpha2]: https://github.com/composer/composer/compare/2.0.0-alpha1...2.0.0-alpha2
[2.0.0-alpha1]: https://github.com/composer/composer/compare/1.10.7...2.0.0-alpha1 [2.0.0-alpha1]: https://github.com/composer/composer/compare/1.10.7...2.0.0-alpha1
[1.10.14]: https://github.com/composer/composer/compare/1.10.13...1.10.14
[1.10.13]: https://github.com/composer/composer/compare/1.10.12...1.10.13 [1.10.13]: https://github.com/composer/composer/compare/1.10.12...1.10.13
[1.10.12]: https://github.com/composer/composer/compare/1.10.11...1.10.12 [1.10.12]: https://github.com/composer/composer/compare/1.10.11...1.10.12
[1.10.11]: https://github.com/composer/composer/compare/1.10.10...1.10.11 [1.10.11]: https://github.com/composer/composer/compare/1.10.10...1.10.11

@ -589,6 +589,17 @@ the branch or tag that is currently checked out. Otherwise, the version should
be explicitly defined in the package's `composer.json` file. If the version be explicitly defined in the package's `composer.json` file. If the version
cannot be resolved by these means, it is assumed to be `dev-master`. cannot be resolved by these means, it is assumed to be `dev-master`.
When the version cannot be inferred from the local VCS repository, you should use
the special `branch-version` entry under `extra` instead of `version`:
```json
{
"extra": {
"branch-version": "4.2-dev"
}
}
```
The local package will be symlinked if possible, in which case the output in The local package will be symlinked if possible, in which case the output in
the console will read `Symlinking from ../../packages/my-package`. If symlinking the console will read `Symlinking from ../../packages/my-package`. If symlinking
is _not_ possible the package will be copied. In that case, the console will is _not_ possible the package will be copied. In that case, the console will

@ -73,8 +73,10 @@ class RootPackageLoader extends ArrayLoader
if (!isset($config['version'])) { if (!isset($config['version'])) {
$commit = null; $commit = null;
// override with env var if available if (isset($config['extra']['branch-version'])) {
if (getenv('COMPOSER_ROOT_VERSION')) { $config['version'] = preg_replace('{(\.x)?(-dev)?$}', '.x-dev', $config['extra']['branch-version']);
} elseif (getenv('COMPOSER_ROOT_VERSION')) {
// override with env var if available
$config['version'] = getenv('COMPOSER_ROOT_VERSION'); $config['version'] = getenv('COMPOSER_ROOT_VERSION');
} else { } else {
$versionData = $this->versionGuesser->guessVersion($config, $cwd ?: getcwd()); $versionData = $this->versionGuesser->guessVersion($config, $cwd ?: getcwd());

@ -171,6 +171,11 @@ class PathRepository extends ArrayRepository implements ConfigurableRepositoryIn
); );
$package['transport-options'] = $this->options; $package['transport-options'] = $this->options;
// 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']);
}
// carry over the root package version if this path repo is in the same git repository as root package // carry over the root package version if this path repo is in the same git repository as root package
if (!isset($package['version']) && ($rootVersion = getenv('COMPOSER_ROOT_VERSION'))) { if (!isset($package['version']) && ($rootVersion = getenv('COMPOSER_ROOT_VERSION'))) {
if ( if (

@ -201,4 +201,15 @@ class RootPackageLoaderTest extends TestCase
$this->assertEquals("dev-latest-production", $package->getPrettyVersion()); $this->assertEquals("dev-latest-production", $package->getPrettyVersion());
} }
public function testLoadExtraBranchVersion()
{
$package = $this->loadPackage(array(
'extra' => array(
'branch-version' => '1.2',
),
));
$this->assertEquals('1.2.x-dev', $package->getPrettyVersion());
}
} }

@ -0,0 +1,6 @@
{
"name": "test/path-branch-versioned",
"extra": {
"branch-version": "1.2"
}
}

@ -69,6 +69,23 @@ class PathRepositoryTest extends TestCase
$this->assertNotEmpty($packageVersion); $this->assertNotEmpty($packageVersion);
} }
public function testLoadPackageFromFileSystemWithExtraBranchVersion()
{
$ioInterface = $this->getMockBuilder('Composer\IO\IOInterface')
->getMock();
$config = new \Composer\Config();
$versionGuesser = null;
$repositoryUrl = implode(DIRECTORY_SEPARATOR, array(__DIR__, 'Fixtures', 'path', 'with-branch-version'));
$repository = new PathRepository(array('url' => $repositoryUrl), $ioInterface, $config);
$packages = $repository->getPackages();
$this->assertEquals(1, $repository->count());
$this->assertTrue($repository->hasPackage($this->getPackage('test/path-branch-versioned', '1.2.x-dev')));
}
public function testLoadPackageFromFileSystemWithWildcard() public function testLoadPackageFromFileSystemWithWildcard()
{ {
$ioInterface = $this->getMockBuilder('Composer\IO\IOInterface') $ioInterface = $this->getMockBuilder('Composer\IO\IOInterface')
@ -82,7 +99,7 @@ class PathRepositoryTest extends TestCase
$packages = $repository->getPackages(); $packages = $repository->getPackages();
$names = array(); $names = array();
$this->assertGreaterThanOrEqual(2, $repository->count()); $this->assertGreaterThanOrEqual(3, $repository->count());
$package = $packages[0]; $package = $packages[0];
$names[] = $package->getName(); $names[] = $package->getName();
@ -90,8 +107,11 @@ class PathRepositoryTest extends TestCase
$package = $packages[count($packages) - 1]; $package = $packages[count($packages) - 1];
$names[] = $package->getName(); $names[] = $package->getName();
$package = $packages[2];
$names[] = $package->getName();
sort($names); sort($names);
$this->assertSame(array('test/path-unversioned', 'test/path-versioned'), $names); $this->assertSame(array('test/path-branch-versioned', 'test/path-unversioned', 'test/path-versioned'), $names);
} }
/** /**

Loading…
Cancel
Save