1
0
Fork 0

Allow requesting a particular vcs driver to bypass github/bitbucket ones

pull/425/head
Jordi Boggiano 2012-03-09 18:30:59 +01:00
parent 6c9f1f6f5b
commit 1d544630b6
3 changed files with 20 additions and 8 deletions

View File

@ -123,8 +123,11 @@ class Factory
$rm = new RepositoryManager($io);
$rm->setRepositoryClass('composer', 'Composer\Repository\ComposerRepository');
$rm->setRepositoryClass('vcs', 'Composer\Repository\VcsRepository');
$rm->setRepositoryClass('pear', 'Composer\Repository\PearRepository');
$rm->setRepositoryClass('package', 'Composer\Repository\PackageRepository');
$rm->setRepositoryClass('pear', 'Composer\Repository\PearRepository');
$rm->setRepositoryClass('git', 'Composer\Repository\VcsRepository');
$rm->setRepositoryClass('svn', 'Composer\Repository\VcsRepository');
$rm->setRepositoryClass('hg', 'Composer\Repository\VcsRepository');
return $rm;
}

View File

@ -20,20 +20,22 @@ class VcsRepository extends ArrayRepository
protected $debug;
protected $io;
protected $versionParser;
protected $type;
public function __construct(array $config, IOInterface $io, array $drivers = null)
{
$this->drivers = $drivers ?: array(
'Composer\Repository\Vcs\GitHubDriver',
'Composer\Repository\Vcs\GitBitbucketDriver',
'Composer\Repository\Vcs\GitDriver',
'Composer\Repository\Vcs\SvnDriver',
'Composer\Repository\Vcs\HgBitbucketDriver',
'Composer\Repository\Vcs\HgDriver',
'github' => 'Composer\Repository\Vcs\GitHubDriver',
'git-bitbucket' => 'Composer\Repository\Vcs\GitBitbucketDriver',
'git' => 'Composer\Repository\Vcs\GitDriver',
'svn' => 'Composer\Repository\Vcs\SvnDriver',
'hg-bitbucket' => 'Composer\Repository\Vcs\HgBitbucketDriver',
'hg' => 'Composer\Repository\Vcs\HgDriver',
);
$this->url = $config['url'];
$this->io = $io;
$this->type = $config['type'];
}
public function setDebug($debug)
@ -43,6 +45,13 @@ class VcsRepository extends ArrayRepository
public function getDriver()
{
if (isset($this->drivers[$this->type])) {
$class = $this->drivers[$this->type];
$driver = new $class($this->url, $this->io);
$driver->initialize();
return $driver;
}
foreach ($this->drivers as $driver) {
if ($driver::supports($this->url)) {
$driver = new $driver($this->url, $this->io);

View File

@ -123,7 +123,7 @@ class VcsRepositoryTest extends \PHPUnit_Framework_TestCase
'dev-master' => true,
);
$repo = new VcsRepository(array('url' => self::$gitRepo), new NullIO);
$repo = new VcsRepository(array('url' => self::$gitRepo, 'type' => 'vcs'), new NullIO);
$packages = $repo->getPackages();
$dumper = new ArrayDumper();