1
0
Fork 0

Allow the loader of the VcsRepository to be overriden

pull/928/head
Jordi Boggiano 2012-07-18 17:21:21 +02:00
parent c65af3e3a1
commit b0151a4ce5
1 changed files with 12 additions and 3 deletions

View File

@ -16,6 +16,7 @@ use Composer\Downloader\TransportException;
use Composer\Repository\Vcs\VcsDriverInterface; use Composer\Repository\Vcs\VcsDriverInterface;
use Composer\Package\Version\VersionParser; use Composer\Package\Version\VersionParser;
use Composer\Package\Loader\ArrayLoader; use Composer\Package\Loader\ArrayLoader;
use Composer\Package\Loader\LoaderInterface;
use Composer\IO\IOInterface; use Composer\IO\IOInterface;
use Composer\Config; use Composer\Config;
@ -31,6 +32,7 @@ class VcsRepository extends ArrayRepository
protected $config; protected $config;
protected $versionParser; protected $versionParser;
protected $type; protected $type;
protected $loader;
public function __construct(array $repoConfig, IOInterface $io, Config $config, array $drivers = null) public function __construct(array $repoConfig, IOInterface $io, Config $config, array $drivers = null)
{ {
@ -50,6 +52,11 @@ class VcsRepository extends ArrayRepository
$this->config = $config; $this->config = $config;
} }
public function setLoader(LoaderInterface $loader)
{
$this->loader = $loader;
}
public function getDriver() public function getDriver()
{ {
if (isset($this->drivers[$this->type])) { if (isset($this->drivers[$this->type])) {
@ -91,7 +98,9 @@ class VcsRepository extends ArrayRepository
} }
$this->versionParser = new VersionParser; $this->versionParser = new VersionParser;
$loader = new ArrayLoader(); if (!$this->loader) {
$this->loader = new ArrayLoader($this->versionParser);
}
try { try {
if ($driver->hasComposerFile($driver->getRootIdentifier())) { if ($driver->hasComposerFile($driver->getRootIdentifier())) {
@ -155,7 +164,7 @@ class VcsRepository extends ArrayRepository
$this->io->write('Importing tag '.$tag.' ('.$data['version_normalized'].')'); $this->io->write('Importing tag '.$tag.' ('.$data['version_normalized'].')');
} }
$this->addPackage($loader->load($this->preProcess($driver, $data, $identifier))); $this->addPackage($this->loader->load($this->preProcess($driver, $data, $identifier)));
} catch (\Exception $e) { } catch (\Exception $e) {
if ($verbose) { if ($verbose) {
$this->io->write('Skipped tag '.$tag.', '.($e instanceof TransportException ? 'no composer file was found' : $e->getMessage())); $this->io->write('Skipped tag '.$tag.', '.($e instanceof TransportException ? 'no composer file was found' : $e->getMessage()));
@ -204,7 +213,7 @@ class VcsRepository extends ArrayRepository
$this->io->write('Importing branch '.$branch.' ('.$data['version'].')'); $this->io->write('Importing branch '.$branch.' ('.$data['version'].')');
} }
$this->addPackage($loader->load($this->preProcess($driver, $data, $identifier))); $this->addPackage($this->loader->load($this->preProcess($driver, $data, $identifier)));
} catch (TransportException $e) { } catch (TransportException $e) {
if ($verbose) { if ($verbose) {
$this->io->write('Skipped branch '.$branch.', no composer file was found'); $this->io->write('Skipped branch '.$branch.', no composer file was found');