diff --git a/doc/05-repositories.md b/doc/05-repositories.md index 2379165bb..d7f5acfa4 100644 --- a/doc/05-repositories.md +++ b/doc/05-repositories.md @@ -400,8 +400,8 @@ 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 `git-bitbucket`, -`hg-bitbucket`, `github`, `gitlab`, `perforce`, `fossil`, `git`, `svn` or `hg` +should you need to specify one for whatever reason, you can use `bitbucket`, +`github`, `gitlab`, `perforce`, `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 @@ -412,6 +412,7 @@ attempt to use github's zip files. Please note: * **To let Composer choose which driver to use** the repository type needs to be defined as "vcs" * **If you already used a private repository**, this means Composer should have cloned it in cache. If you want to install the same package with drivers, remember to launch the command `composer clearcache` followed by the command `composer update` to update Composer cache and install the package from dist. +* VCS driver `git-bitbucket` is deprecated in favor of `bitbucket` #### BitBucket Driver Configuration diff --git a/res/composer-schema.json b/res/composer-schema.json index bb86996e7..e079bb962 100644 --- a/res/composer-schema.json +++ b/res/composer-schema.json @@ -701,7 +701,7 @@ "type": "object", "required": ["type", "url"], "properties": { - "type": { "type": "string", "enum": ["vcs", "github", "git", "gitlab", "git-bitbucket", "hg", "hg-bitbucket", "fossil", "perforce", "svn"] }, + "type": { "type": "string", "enum": ["vcs", "github", "git", "gitlab", "bitbucket", "git-bitbucket", "hg", "fossil", "perforce", "svn"] }, "url": { "type": "string" }, "canonical": { "type": "boolean" }, "only": { diff --git a/src/Composer/Repository/RepositoryFactory.php b/src/Composer/Repository/RepositoryFactory.php index 713d4d9c0..a5e0e9f31 100644 --- a/src/Composer/Repository/RepositoryFactory.php +++ b/src/Composer/Repository/RepositoryFactory.php @@ -125,6 +125,7 @@ class RepositoryFactory $rm->setRepositoryClass('package', 'Composer\Repository\PackageRepository'); $rm->setRepositoryClass('pear', 'Composer\Repository\PearRepository'); $rm->setRepositoryClass('git', 'Composer\Repository\VcsRepository'); + $rm->setRepositoryClass('bitbucket', 'Composer\Repository\VcsRepository'); $rm->setRepositoryClass('git-bitbucket', 'Composer\Repository\VcsRepository'); $rm->setRepositoryClass('github', 'Composer\Repository\VcsRepository'); $rm->setRepositoryClass('gitlab', 'Composer\Repository\VcsRepository'); @@ -132,7 +133,6 @@ class RepositoryFactory $rm->setRepositoryClass('fossil', 'Composer\Repository\VcsRepository'); $rm->setRepositoryClass('perforce', 'Composer\Repository\VcsRepository'); $rm->setRepositoryClass('hg', 'Composer\Repository\VcsRepository'); - $rm->setRepositoryClass('hg-bitbucket', 'Composer\Repository\VcsRepository'); $rm->setRepositoryClass('artifact', 'Composer\Repository\ArtifactRepository'); $rm->setRepositoryClass('path', 'Composer\Repository\PathRepository'); diff --git a/src/Composer/Repository/Vcs/GitBitbucketDriver.php b/src/Composer/Repository/Vcs/GitBitbucketDriver.php index df80ea25c..20b49aa8b 100644 --- a/src/Composer/Repository/Vcs/GitBitbucketDriver.php +++ b/src/Composer/Repository/Vcs/GitBitbucketDriver.php @@ -41,7 +41,8 @@ class GitBitbucketDriver extends BitbucketDriver if ($this->vcsType !== 'git') { throw new \RuntimeException( $this->url.' does not appear to be a git repository, use '. - $this->cloneHttpsUrl.' if this is a mercurial bitbucket repository' + $this->cloneHttpsUrl.' but remember that Bitbucket no longer supports the mercurial repositories. '. + 'https://bitbucket.org/blog/sunsetting-mercurial-support-in-bitbucket' ); } diff --git a/src/Composer/Repository/Vcs/HgBitbucketDriver.php b/src/Composer/Repository/Vcs/HgBitbucketDriver.php deleted file mode 100644 index bd6734690..000000000 --- a/src/Composer/Repository/Vcs/HgBitbucketDriver.php +++ /dev/null @@ -1,95 +0,0 @@ - - * Jordi Boggiano - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Composer\Repository\Vcs; - -use Composer\Config; -use Composer\IO\IOInterface; - -/** - * @author Per Bernhardt - */ -class HgBitbucketDriver extends BitbucketDriver -{ - /** - * @inheritDoc - */ - public function getRootIdentifier() - { - if ($this->fallbackDriver) { - return $this->fallbackDriver->getRootIdentifier(); - } - - if (null === $this->rootIdentifier) { - if (!$this->getRepoData()) { - if (!$this->fallbackDriver) { - throw new \LogicException('A fallback driver should be setup if getRepoData returns false'); - } - - return $this->fallbackDriver->getRootIdentifier(); - } - - if ($this->vcsType !== 'hg') { - throw new \RuntimeException( - $this->url.' does not appear to be a mercurial repository, use '. - $this->cloneHttpsUrl.' if this is a git bitbucket repository' - ); - } - - $mainBranchData = $this->getMainBranchData(); - $this->rootIdentifier = !empty($mainBranchData['name']) ? $mainBranchData['name'] : 'default'; - } - - return $this->rootIdentifier; - } - - /** - * @inheritDoc - */ - public static function supports(IOInterface $io, Config $config, $url, $deep = false) - { - if (!preg_match('#^https?://bitbucket\.org/([^/]+)/([^/]+)/?$#i', $url)) { - return false; - } - - if (!extension_loaded('openssl')) { - $io->writeError('Skipping Bitbucket hg driver for '.$url.' because the OpenSSL PHP extension is missing.', true, IOInterface::VERBOSE); - - return false; - } - - return true; - } - - /** - * @inheritDoc - */ - protected function setupFallbackDriver($url) - { - $this->fallbackDriver = new HgDriver( - array('url' => $url), - $this->io, - $this->config, - $this->httpDownloader, - $this->process - ); - $this->fallbackDriver->initialize(); - } - - /** - * @inheritDoc - */ - protected function generateSshUrl() - { - return 'ssh://hg@' . $this->originUrl . '/' . $this->owner.'/'.$this->repository; - } -} diff --git a/src/Composer/Repository/VcsRepository.php b/src/Composer/Repository/VcsRepository.php index 8469a33c8..a988ada34 100644 --- a/src/Composer/Repository/VcsRepository.php +++ b/src/Composer/Repository/VcsRepository.php @@ -79,9 +79,9 @@ class VcsRepository extends ArrayRepository implements ConfigurableRepositoryInt $this->drivers = $drivers ?: array( 'github' => 'Composer\Repository\Vcs\GitHubDriver', 'gitlab' => 'Composer\Repository\Vcs\GitLabDriver', + 'bitbucket' => 'Composer\Repository\Vcs\GitBitbucketDriver', 'git-bitbucket' => 'Composer\Repository\Vcs\GitBitbucketDriver', 'git' => 'Composer\Repository\Vcs\GitDriver', - 'hg-bitbucket' => 'Composer\Repository\Vcs\HgBitbucketDriver', 'hg' => 'Composer\Repository\Vcs\HgDriver', 'perforce' => 'Composer\Repository\Vcs\PerforceDriver', 'fossil' => 'Composer\Repository\Vcs\FossilDriver', diff --git a/tests/Composer/Test/Repository/RepositoryFactoryTest.php b/tests/Composer/Test/Repository/RepositoryFactoryTest.php index f64bf0aca..ab725b18f 100644 --- a/tests/Composer/Test/Repository/RepositoryFactoryTest.php +++ b/tests/Composer/Test/Repository/RepositoryFactoryTest.php @@ -36,6 +36,7 @@ class RepositoryFactoryTest extends TestCase 'package', 'pear', 'git', + 'bitbucket', 'git-bitbucket', 'github', 'gitlab', @@ -43,7 +44,6 @@ class RepositoryFactoryTest extends TestCase 'fossil', 'perforce', 'hg', - 'hg-bitbucket', 'artifact', 'path', ), array_keys($repositoryClasses)); diff --git a/tests/Composer/Test/Repository/Vcs/GitBitbucketDriverTest.php b/tests/Composer/Test/Repository/Vcs/GitBitbucketDriverTest.php index 89cc7f7f5..43e9293d8 100644 --- a/tests/Composer/Test/Repository/Vcs/GitBitbucketDriverTest.php +++ b/tests/Composer/Test/Repository/Vcs/GitBitbucketDriverTest.php @@ -84,7 +84,7 @@ class GitBitbucketDriverTest extends TestCase { $this->setExpectedException( '\RuntimeException', - 'https://bitbucket.org/user/repo.git does not appear to be a git repository, use https://bitbucket.org/user/repo if this is a mercurial bitbucket repository' + 'https://bitbucket.org/user/repo.git does not appear to be a git repository, use https://bitbucket.org/user/repo but remember that Bitbucket no longer supports the mercurial repositories. https://bitbucket.org/blog/sunsetting-mercurial-support-in-bitbucket' ); $this->httpDownloader->expects($this->once())