Remove redundant __contruct from VcsDriver implementations and move init code to initialize method
parent
017ebabcb5
commit
949728f812
|
@ -27,20 +27,14 @@ class GitBitbucketDriver extends VcsDriver implements VcsDriverInterface
|
|||
protected $rootIdentifier;
|
||||
protected $infoCache = array();
|
||||
|
||||
public function __construct($url, IOInterface $io)
|
||||
{
|
||||
preg_match('#^https://bitbucket\.org/([^/]+)/(.+?)\.git$#', $url, $match);
|
||||
$this->owner = $match[1];
|
||||
$this->repository = $match[2];
|
||||
|
||||
parent::__construct($url, $io);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function initialize()
|
||||
{
|
||||
preg_match('#^https://bitbucket\.org/([^/]+)/(.+?)\.git$#', $this->url, $match);
|
||||
$this->owner = $match[1];
|
||||
$this->repository = $match[2];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -28,11 +28,6 @@ class GitDriver extends VcsDriver
|
|||
protected $repoDir;
|
||||
protected $infoCache = array();
|
||||
|
||||
public function __construct($url, IOInterface $io, ProcessExecutor $process = null)
|
||||
{
|
||||
parent::__construct($url, $io, $process);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
|
|
@ -38,28 +38,15 @@ class GitHubDriver extends VcsDriver
|
|||
*/
|
||||
protected $gitDriver;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $url
|
||||
* @param IOInterface $io
|
||||
* @param ProcessExecutor $process
|
||||
* @param RemoteFilesystem $remoteFilesystem
|
||||
*/
|
||||
public function __construct($url, IOInterface $io, ProcessExecutor $process = null, RemoteFilesystem $remoteFilesystem = null)
|
||||
{
|
||||
preg_match('#^(?:https?|git)://github\.com/([^/]+)/(.+?)(?:\.git)?$#', $url, $match);
|
||||
$this->owner = $match[1];
|
||||
$this->repository = $match[2];
|
||||
|
||||
parent::__construct($url, $io, $process, $remoteFilesystem);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function initialize()
|
||||
{
|
||||
preg_match('#^(?:https?|git)://github\.com/([^/]+)/(.+?)(?:\.git)?$#', $this->url, $match);
|
||||
$this->owner = $match[1];
|
||||
$this->repository = $match[2];
|
||||
|
||||
$this->fetchRootIdentifier();
|
||||
}
|
||||
|
||||
|
|
|
@ -27,20 +27,14 @@ class HgBitbucketDriver extends VcsDriver
|
|||
protected $rootIdentifier;
|
||||
protected $infoCache = array();
|
||||
|
||||
public function __construct($url, IOInterface $io)
|
||||
{
|
||||
preg_match('#^https://bitbucket\.org/([^/]+)/([^/]+)/?$#', $url, $match);
|
||||
$this->owner = $match[1];
|
||||
$this->repository = $match[2];
|
||||
|
||||
parent::__construct($url, $io);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function initialize()
|
||||
{
|
||||
preg_match('#^https://bitbucket\.org/([^/]+)/([^/]+)/?$#', $this->url, $match);
|
||||
$this->owner = $match[1];
|
||||
$this->repository = $match[2];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -26,18 +26,13 @@ class HgDriver extends VcsDriver
|
|||
protected $rootIdentifier;
|
||||
protected $infoCache = array();
|
||||
|
||||
public function __construct($url, IOInterface $io, ProcessExecutor $process = null)
|
||||
{
|
||||
$this->tmpDir = sys_get_temp_dir() . '/composer-' . preg_replace('{[^a-z0-9]}i', '-', $url) . '/';
|
||||
|
||||
parent::__construct($url, $io, $process);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function initialize()
|
||||
{
|
||||
$this->tmpDir = sys_get_temp_dir() . '/composer-' . preg_replace('{[^a-z0-9]}i', '-', $url) . '/';
|
||||
|
||||
$url = escapeshellarg($this->url);
|
||||
$tmpDir = escapeshellarg($this->tmpDir);
|
||||
if (is_dir($this->tmpDir)) {
|
||||
|
|
|
@ -35,24 +35,6 @@ class SvnDriver extends VcsDriver
|
|||
*/
|
||||
protected $util;
|
||||
|
||||
/**
|
||||
* @param string $url
|
||||
* @param IOInterface $io
|
||||
* @param ProcessExecutor $process
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function __construct($url, IOInterface $io, ProcessExecutor $process = null)
|
||||
{
|
||||
$url = self::normalizeUrl($url);
|
||||
parent::__construct($this->baseUrl = rtrim($url, '/'), $io, $process);
|
||||
|
||||
if (false !== ($pos = strrpos($url, '/trunk'))) {
|
||||
$this->baseUrl = substr($url, 0, $pos);
|
||||
}
|
||||
$this->util = new SvnUtil($this->baseUrl, $io, $this->process);
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute an SVN command and try to fix up the process with credentials
|
||||
* if necessary.
|
||||
|
@ -78,6 +60,13 @@ class SvnDriver extends VcsDriver
|
|||
*/
|
||||
public function initialize()
|
||||
{
|
||||
$this->url = rtrim(self::normalizeUrl($this->url), '/');
|
||||
|
||||
if (false !== ($pos = strrpos($url, '/trunk'))) {
|
||||
$this->baseUrl = substr($url, 0, $pos);
|
||||
}
|
||||
$this->util = new SvnUtil($this->baseUrl, $this->io, $this->process);
|
||||
|
||||
$this->getBranches();
|
||||
$this->getTags();
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ abstract class VcsDriver implements VcsDriverInterface
|
|||
* @param ProcessExecutor $process Process instance, injectable for mocking
|
||||
* @param callable $remoteFilesystem Remote Filesystem, injectable for mocking
|
||||
*/
|
||||
public function __construct($url, IOInterface $io, Config $config, ProcessExecutor $process = null, $remoteFilesystem = null)
|
||||
final public function __construct($url, IOInterface $io, Config $config, ProcessExecutor $process = null, $remoteFilesystem = null)
|
||||
{
|
||||
$this->url = $url;
|
||||
$this->io = $io;
|
||||
|
|
Loading…
Reference in New Issue