diff --git a/src/Composer/Factory.php b/src/Composer/Factory.php index 4fefb31af..3f4812927 100644 --- a/src/Composer/Factory.php +++ b/src/Composer/Factory.php @@ -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; } diff --git a/src/Composer/Repository/VcsRepository.php b/src/Composer/Repository/VcsRepository.php index fa37a62aa..490f807e0 100644 --- a/src/Composer/Repository/VcsRepository.php +++ b/src/Composer/Repository/VcsRepository.php @@ -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); diff --git a/tests/Composer/Test/Repository/VcsRepositoryTest.php b/tests/Composer/Test/Repository/VcsRepositoryTest.php index 255162354..7c008f24f 100644 --- a/tests/Composer/Test/Repository/VcsRepositoryTest.php +++ b/tests/Composer/Test/Repository/VcsRepositoryTest.php @@ -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();