From 079e501ac8676db4b793bff18da84388daeff55e Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Wed, 27 Jan 2021 14:03:44 +0100 Subject: [PATCH] Revert "Merge pull request #9273 from nicolas-grekas/dev-version" This reverts commit d2d606ced201722dc56b759933bec4c688e7d994, reversing changes made to 4a8dbcd1451b7fd1e3537dee2302549587db8e2c. --- doc/05-repositories.md | 11 --------- .../Package/Loader/RootPackageLoader.php | 6 ++--- src/Composer/Repository/PathRepository.php | 5 ---- .../Package/Loader/RootPackageLoaderTest.php | 24 ------------------- .../path/with-branch-version/composer.json | 6 ----- .../Test/Repository/PathRepositoryTest.php | 24 ++----------------- 6 files changed, 4 insertions(+), 72 deletions(-) delete mode 100644 tests/Composer/Test/Repository/Fixtures/path/with-branch-version/composer.json diff --git a/doc/05-repositories.md b/doc/05-repositories.md index cd3266285..95881b078 100644 --- a/doc/05-repositories.md +++ b/doc/05-repositories.md @@ -658,17 +658,6 @@ 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 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 console will read `Symlinking from ../../packages/my-package`. If symlinking is _not_ possible the package will be copied. In that case, the console will diff --git a/src/Composer/Package/Loader/RootPackageLoader.php b/src/Composer/Package/Loader/RootPackageLoader.php index 5eceec97d..32118b113 100644 --- a/src/Composer/Package/Loader/RootPackageLoader.php +++ b/src/Composer/Package/Loader/RootPackageLoader.php @@ -81,10 +81,8 @@ class RootPackageLoader extends ArrayLoader if (!isset($config['version'])) { $commit = null; - if (isset($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 + // override with env var if available + if (getenv('COMPOSER_ROOT_VERSION')) { $config['version'] = getenv('COMPOSER_ROOT_VERSION'); } else { $versionData = $this->versionGuesser->guessVersion($config, $cwd ?: getcwd()); diff --git a/src/Composer/Repository/PathRepository.php b/src/Composer/Repository/PathRepository.php index c3076e2e7..a0a6835b8 100644 --- a/src/Composer/Repository/PathRepository.php +++ b/src/Composer/Repository/PathRepository.php @@ -165,11 +165,6 @@ class PathRepository extends ArrayRepository implements ConfigurableRepositoryIn ); $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)?$}', '', $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 if (!isset($package['version']) && ($rootVersion = getenv('COMPOSER_ROOT_VERSION'))) { if ( diff --git a/tests/Composer/Test/Package/Loader/RootPackageLoaderTest.php b/tests/Composer/Test/Package/Loader/RootPackageLoaderTest.php index c50cc77e0..858e95231 100644 --- a/tests/Composer/Test/Package/Loader/RootPackageLoaderTest.php +++ b/tests/Composer/Test/Package/Loader/RootPackageLoaderTest.php @@ -201,28 +201,4 @@ class RootPackageLoaderTest extends TestCase $this->assertEquals("dev-latest-production", $package->getPrettyVersion()); } - - /** - * @dataProvider provideExtraBranchVersion - */ - public function testLoadExtraBranchVersion($branchVersion) - { - $package = $this->loadPackage(array( - 'extra' => array( - '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'), - ); - } } diff --git a/tests/Composer/Test/Repository/Fixtures/path/with-branch-version/composer.json b/tests/Composer/Test/Repository/Fixtures/path/with-branch-version/composer.json deleted file mode 100644 index 75545d5f9..000000000 --- a/tests/Composer/Test/Repository/Fixtures/path/with-branch-version/composer.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "test/path-branch-versioned", - "extra": { - "branch-version": "1.2" - } -} diff --git a/tests/Composer/Test/Repository/PathRepositoryTest.php b/tests/Composer/Test/Repository/PathRepositoryTest.php index 628c3320d..159d8cc97 100644 --- a/tests/Composer/Test/Repository/PathRepositoryTest.php +++ b/tests/Composer/Test/Repository/PathRepositoryTest.php @@ -72,23 +72,6 @@ class PathRepositoryTest extends TestCase $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() { $ioInterface = $this->getMockBuilder('Composer\IO\IOInterface') @@ -102,7 +85,7 @@ class PathRepositoryTest extends TestCase $packages = $repository->getPackages(); $names = array(); - $this->assertEquals(3, $repository->count()); + $this->assertEquals(2, $repository->count()); $package = $packages[0]; $names[] = $package->getName(); @@ -110,11 +93,8 @@ class PathRepositoryTest extends TestCase $package = $packages[1]; $names[] = $package->getName(); - $package = $packages[2]; - $names[] = $package->getName(); - sort($names); - $this->assertEquals(array('test/path-branch-versioned', 'test/path-unversioned', 'test/path-versioned'), $names); + $this->assertEquals(array('test/path-unversioned', 'test/path-versioned'), $names); } /**