Allow requesting a particular vcs driver to bypass github/bitbucket ones
parent
6c9f1f6f5b
commit
1d544630b6
|
@ -123,8 +123,11 @@ class Factory
|
||||||
$rm = new RepositoryManager($io);
|
$rm = new RepositoryManager($io);
|
||||||
$rm->setRepositoryClass('composer', 'Composer\Repository\ComposerRepository');
|
$rm->setRepositoryClass('composer', 'Composer\Repository\ComposerRepository');
|
||||||
$rm->setRepositoryClass('vcs', 'Composer\Repository\VcsRepository');
|
$rm->setRepositoryClass('vcs', 'Composer\Repository\VcsRepository');
|
||||||
$rm->setRepositoryClass('pear', 'Composer\Repository\PearRepository');
|
|
||||||
$rm->setRepositoryClass('package', 'Composer\Repository\PackageRepository');
|
$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;
|
return $rm;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,20 +20,22 @@ class VcsRepository extends ArrayRepository
|
||||||
protected $debug;
|
protected $debug;
|
||||||
protected $io;
|
protected $io;
|
||||||
protected $versionParser;
|
protected $versionParser;
|
||||||
|
protected $type;
|
||||||
|
|
||||||
public function __construct(array $config, IOInterface $io, array $drivers = null)
|
public function __construct(array $config, IOInterface $io, array $drivers = null)
|
||||||
{
|
{
|
||||||
$this->drivers = $drivers ?: array(
|
$this->drivers = $drivers ?: array(
|
||||||
'Composer\Repository\Vcs\GitHubDriver',
|
'github' => 'Composer\Repository\Vcs\GitHubDriver',
|
||||||
'Composer\Repository\Vcs\GitBitbucketDriver',
|
'git-bitbucket' => 'Composer\Repository\Vcs\GitBitbucketDriver',
|
||||||
'Composer\Repository\Vcs\GitDriver',
|
'git' => 'Composer\Repository\Vcs\GitDriver',
|
||||||
'Composer\Repository\Vcs\SvnDriver',
|
'svn' => 'Composer\Repository\Vcs\SvnDriver',
|
||||||
'Composer\Repository\Vcs\HgBitbucketDriver',
|
'hg-bitbucket' => 'Composer\Repository\Vcs\HgBitbucketDriver',
|
||||||
'Composer\Repository\Vcs\HgDriver',
|
'hg' => 'Composer\Repository\Vcs\HgDriver',
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->url = $config['url'];
|
$this->url = $config['url'];
|
||||||
$this->io = $io;
|
$this->io = $io;
|
||||||
|
$this->type = $config['type'];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setDebug($debug)
|
public function setDebug($debug)
|
||||||
|
@ -43,6 +45,13 @@ class VcsRepository extends ArrayRepository
|
||||||
|
|
||||||
public function getDriver()
|
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) {
|
foreach ($this->drivers as $driver) {
|
||||||
if ($driver::supports($this->url)) {
|
if ($driver::supports($this->url)) {
|
||||||
$driver = new $driver($this->url, $this->io);
|
$driver = new $driver($this->url, $this->io);
|
||||||
|
|
|
@ -123,7 +123,7 @@ class VcsRepositoryTest extends \PHPUnit_Framework_TestCase
|
||||||
'dev-master' => true,
|
'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();
|
$packages = $repo->getPackages();
|
||||||
$dumper = new ArrayDumper();
|
$dumper = new ArrayDumper();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue