1
0
Fork 0
mirror of https://github.com/composer/composer synced 2025-05-10 17:12:51 +00:00

Removed HgBitbucketDriver support (#10248)

This commit is contained in:
Raphael de Almeida 2021-11-10 17:58:03 -03:00 committed by GitHub
parent ba5b7a5a9f
commit 150acc5559
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 10 additions and 103 deletions

View file

@ -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) * **BitBucket:** [bitbucket.org](https://bitbucket.org) (Git and Mercurial)
The VCS driver to be used is detected automatically based on the URL. However, 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`, should you need to specify one for whatever reason, you can use `bitbucket`,
`hg-bitbucket`, `github`, `gitlab`, `perforce`, `fossil`, `git`, `svn` or `hg` `github`, `gitlab`, `perforce`, `fossil`, `git`, `svn` or `hg`
as the repository type instead of `vcs`. as the repository type instead of `vcs`.
If you set the `no-api` key to `true` on a github repository it will clone the 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: Please note:
* **To let Composer choose which driver to use** the repository type needs to be defined as "vcs" * **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. * **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 #### BitBucket Driver Configuration

View file

@ -701,7 +701,7 @@
"type": "object", "type": "object",
"required": ["type", "url"], "required": ["type", "url"],
"properties": { "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" }, "url": { "type": "string" },
"canonical": { "type": "boolean" }, "canonical": { "type": "boolean" },
"only": { "only": {

View file

@ -125,6 +125,7 @@ class RepositoryFactory
$rm->setRepositoryClass('package', 'Composer\Repository\PackageRepository'); $rm->setRepositoryClass('package', 'Composer\Repository\PackageRepository');
$rm->setRepositoryClass('pear', 'Composer\Repository\PearRepository'); $rm->setRepositoryClass('pear', 'Composer\Repository\PearRepository');
$rm->setRepositoryClass('git', 'Composer\Repository\VcsRepository'); $rm->setRepositoryClass('git', 'Composer\Repository\VcsRepository');
$rm->setRepositoryClass('bitbucket', 'Composer\Repository\VcsRepository');
$rm->setRepositoryClass('git-bitbucket', 'Composer\Repository\VcsRepository'); $rm->setRepositoryClass('git-bitbucket', 'Composer\Repository\VcsRepository');
$rm->setRepositoryClass('github', 'Composer\Repository\VcsRepository'); $rm->setRepositoryClass('github', 'Composer\Repository\VcsRepository');
$rm->setRepositoryClass('gitlab', 'Composer\Repository\VcsRepository'); $rm->setRepositoryClass('gitlab', 'Composer\Repository\VcsRepository');
@ -132,7 +133,6 @@ class RepositoryFactory
$rm->setRepositoryClass('fossil', 'Composer\Repository\VcsRepository'); $rm->setRepositoryClass('fossil', 'Composer\Repository\VcsRepository');
$rm->setRepositoryClass('perforce', 'Composer\Repository\VcsRepository'); $rm->setRepositoryClass('perforce', 'Composer\Repository\VcsRepository');
$rm->setRepositoryClass('hg', 'Composer\Repository\VcsRepository'); $rm->setRepositoryClass('hg', 'Composer\Repository\VcsRepository');
$rm->setRepositoryClass('hg-bitbucket', 'Composer\Repository\VcsRepository');
$rm->setRepositoryClass('artifact', 'Composer\Repository\ArtifactRepository'); $rm->setRepositoryClass('artifact', 'Composer\Repository\ArtifactRepository');
$rm->setRepositoryClass('path', 'Composer\Repository\PathRepository'); $rm->setRepositoryClass('path', 'Composer\Repository\PathRepository');

View file

@ -41,7 +41,8 @@ class GitBitbucketDriver extends BitbucketDriver
if ($this->vcsType !== 'git') { if ($this->vcsType !== 'git') {
throw new \RuntimeException( throw new \RuntimeException(
$this->url.' does not appear to be a git repository, use '. $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'
); );
} }

View file

@ -1,95 +0,0 @@
<?php
/*
* This file is part of Composer.
*
* (c) Nils Adermann <naderman@naderman.de>
* Jordi Boggiano <j.boggiano@seld.be>
*
* 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 <plb@webfactory.de>
*/
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;
}
}

View file

@ -79,9 +79,9 @@ class VcsRepository extends ArrayRepository implements ConfigurableRepositoryInt
$this->drivers = $drivers ?: array( $this->drivers = $drivers ?: array(
'github' => 'Composer\Repository\Vcs\GitHubDriver', 'github' => 'Composer\Repository\Vcs\GitHubDriver',
'gitlab' => 'Composer\Repository\Vcs\GitLabDriver', 'gitlab' => 'Composer\Repository\Vcs\GitLabDriver',
'bitbucket' => 'Composer\Repository\Vcs\GitBitbucketDriver',
'git-bitbucket' => 'Composer\Repository\Vcs\GitBitbucketDriver', 'git-bitbucket' => 'Composer\Repository\Vcs\GitBitbucketDriver',
'git' => 'Composer\Repository\Vcs\GitDriver', 'git' => 'Composer\Repository\Vcs\GitDriver',
'hg-bitbucket' => 'Composer\Repository\Vcs\HgBitbucketDriver',
'hg' => 'Composer\Repository\Vcs\HgDriver', 'hg' => 'Composer\Repository\Vcs\HgDriver',
'perforce' => 'Composer\Repository\Vcs\PerforceDriver', 'perforce' => 'Composer\Repository\Vcs\PerforceDriver',
'fossil' => 'Composer\Repository\Vcs\FossilDriver', 'fossil' => 'Composer\Repository\Vcs\FossilDriver',

View file

@ -36,6 +36,7 @@ class RepositoryFactoryTest extends TestCase
'package', 'package',
'pear', 'pear',
'git', 'git',
'bitbucket',
'git-bitbucket', 'git-bitbucket',
'github', 'github',
'gitlab', 'gitlab',
@ -43,7 +44,6 @@ class RepositoryFactoryTest extends TestCase
'fossil', 'fossil',
'perforce', 'perforce',
'hg', 'hg',
'hg-bitbucket',
'artifact', 'artifact',
'path', 'path',
), array_keys($repositoryClasses)); ), array_keys($repositoryClasses));

View file

@ -84,7 +84,7 @@ class GitBitbucketDriverTest extends TestCase
{ {
$this->setExpectedException( $this->setExpectedException(
'\RuntimeException', '\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()) $this->httpDownloader->expects($this->once())