From e38ebefc7e644899478c46e24657a6cccc5b8b5b Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Thu, 3 Nov 2016 10:59:59 +0100 Subject: [PATCH] Update packagist default repo to be packagist.org --- doc/05-repositories.md | 4 ++-- src/Composer/Config.php | 21 +++++++++++++++---- .../Test/Json/JsonManipulatorTest.php | 4 ++-- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/doc/05-repositories.md b/doc/05-repositories.md index bd1d24cbb..e547b5632 100644 --- a/doc/05-repositories.md +++ b/doc/05-repositories.md @@ -284,7 +284,7 @@ VCS repository provides `dist`s for them that fetch the packages as zips. * **BitBucket:** [bitbucket.org](https://bitbucket.org) (Git and Mercurial) The VCS driver to be used is detected automatically based on the URL. However, -should you need to specify one for whatever reason, you can use `fossil`, +should you need to specify one for whatever reason, you can use `fossil`, `git`, `svn` or `hg` as the repository type instead of `vcs`. If you set the `no-api` key to `true` on a github repository it will clone the @@ -662,7 +662,7 @@ You can disable the default Packagist repository by adding this to your { "repositories": [ { - "packagist": false + "packagist.org": false } ] } diff --git a/src/Composer/Config.php b/src/Composer/Config.php index b05a74294..809dcb10e 100644 --- a/src/Composer/Config.php +++ b/src/Composer/Config.php @@ -68,7 +68,7 @@ class Config ); public static $defaultRepositories = array( - 'packagist' => array( + 'packagist.org' => array( 'type' => 'composer', 'url' => 'https?://packagist.org', 'allow_ssl_downgrade' => true, @@ -158,13 +158,13 @@ class Config foreach ($newRepos as $name => $repository) { // disable a repository by name if (false === $repository) { - unset($this->repositories[$name]); + $this->disableRepoByName($name); continue; } // disable a repository with an anonymous {"name": false} repo if (is_array($repository) && 1 === count($repository) && false === current($repository)) { - unset($this->repositories[key($repository)]); + $this->disableRepoByName(key($repository)); continue; } @@ -172,7 +172,11 @@ class Config if (is_int($name)) { $this->repositories[] = $repository; } else { - $this->repositories[$name] = $repository; + if ($name === 'packagist') { // BC support for default "packagist" named repo + $this->repositories[$name . '.org'] = $repository; + } else { + $this->repositories[$name] = $repository; + } } } $this->repositories = array_reverse($this->repositories, true); @@ -405,6 +409,15 @@ class Config return false; } + private function disableRepoByName($name) + { + if (isset($this->repositories[$name])) { + unset($this->repositories[$name]); + } else if ($name === 'packagist') { // BC support for default "packagist" named repo + unset($this->repositories['packagist.org']); + } + } + /** * Validates that the passed URL is allowed to be used by current config, or throws an exception. * diff --git a/tests/Composer/Test/Json/JsonManipulatorTest.php b/tests/Composer/Test/Json/JsonManipulatorTest.php index 2652ad0b5..893350a3f 100644 --- a/tests/Composer/Test/Json/JsonManipulatorTest.php +++ b/tests/Composer/Test/Json/JsonManipulatorTest.php @@ -292,7 +292,7 @@ class JsonManipulatorTest extends \PHPUnit_Framework_TestCase }, "repositories": [ { - "packagist": false + "packagist.org": false }, { "type": "package", @@ -773,7 +773,7 @@ class JsonManipulatorTest extends \PHPUnit_Framework_TestCase }, "repositories": [ { - "packagist": false + "packagist.org": false }, { "type": "package",