Add warning in verbose mode if drivers can not be used because of missing openssl
parent
4bed779601
commit
6d5b4d606c
|
@ -143,8 +143,19 @@ class GitBitbucketDriver extends VcsDriver implements VcsDriverInterface
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public static function supports($url, $deep = false)
|
public static function supports(IOInterface $io, $url, $deep = false)
|
||||||
{
|
{
|
||||||
return preg_match('#^https://bitbucket\.org/([^/]+)/(.+?)\.git$#', $url);
|
if (!preg_match('#^https://bitbucket\.org/([^/]+)/(.+?)\.git$#', $url)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!extension_loaded('openssl')) {
|
||||||
|
if ($io->isVerbose()) {
|
||||||
|
$io->write('Skipping Bitbucket git driver for '.$url.' because the OpenSSL PHP extension is missing.');
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -184,7 +184,7 @@ class GitDriver extends VcsDriver
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public static function supports($url, $deep = false)
|
public static function supports(IOInterface $io, $url, $deep = false)
|
||||||
{
|
{
|
||||||
if (preg_match('#(^git://|\.git$|git@|//git\.)#i', $url)) {
|
if (preg_match('#(^git://|\.git$|git@|//git\.)#i', $url)) {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -186,9 +186,20 @@ class GitHubDriver extends VcsDriver
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public static function supports($url, $deep = false)
|
public static function supports(IOInterface $io, $url, $deep = false)
|
||||||
{
|
{
|
||||||
return extension_loaded('openssl') && preg_match('#^(?:https?|git)://github\.com/([^/]+)/(.+?)(?:\.git)?$#', $url);
|
if (!preg_match('#^(?:https?|git)://github\.com/([^/]+)/(.+?)(?:\.git)?$#', $url)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!extension_loaded('openssl')) {
|
||||||
|
if ($io->isVerbose()) {
|
||||||
|
$io->write('Skipping GitHub driver for '.$url.' because the OpenSSL PHP extension is missing.');
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -143,8 +143,19 @@ class HgBitbucketDriver extends VcsDriver
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public static function supports($url, $deep = false)
|
public static function supports(IOInterface $io, $url, $deep = false)
|
||||||
{
|
{
|
||||||
return extension_loaded('openssl') && preg_match('#^https://bitbucket\.org/([^/]+)/([^/]+)/?$#', $url);
|
if (!preg_match('#^https://bitbucket\.org/([^/]+)/([^/]+)/?$#', $url)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!extension_loaded('openssl')) {
|
||||||
|
if ($io->isVerbose()) {
|
||||||
|
$io->write('Skipping Bitbucket hg driver for '.$url.' because the OpenSSL PHP extension is missing.');
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -162,7 +162,7 @@ class HgDriver extends VcsDriver
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public static function supports($url, $deep = false)
|
public static function supports(IOInterface $io, $url, $deep = false)
|
||||||
{
|
{
|
||||||
if (preg_match('#(^(?:https?|ssh)://(?:[^@]@)?bitbucket.org|https://(?:.*?)\.kilnhg.com)#i', $url)) {
|
if (preg_match('#(^(?:https?|ssh)://(?:[^@]@)?bitbucket.org|https://(?:.*?)\.kilnhg.com)#i', $url)) {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -218,7 +218,7 @@ class SvnDriver extends VcsDriver
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public static function supports($url, $deep = false)
|
public static function supports(IOInterface $io, $url, $deep = false)
|
||||||
{
|
{
|
||||||
$url = self::normalizeUrl($url);
|
$url = self::normalizeUrl($url);
|
||||||
if (preg_match('#(^svn://|^svn\+ssh://|svn\.)#i', $url)) {
|
if (preg_match('#(^svn://|^svn\+ssh://|svn\.)#i', $url)) {
|
||||||
|
|
|
@ -12,6 +12,8 @@
|
||||||
|
|
||||||
namespace Composer\Repository\Vcs;
|
namespace Composer\Repository\Vcs;
|
||||||
|
|
||||||
|
use Composer\IO\IOInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||||
*/
|
*/
|
||||||
|
@ -82,9 +84,10 @@ interface VcsDriverInterface
|
||||||
/**
|
/**
|
||||||
* Checks if this driver can handle a given url
|
* Checks if this driver can handle a given url
|
||||||
*
|
*
|
||||||
|
* @param IOInterface $io IO instance
|
||||||
* @param string $url
|
* @param string $url
|
||||||
* @param Boolean $shallow unless true, only shallow checks (url matching typically) should be done
|
* @param Boolean $shallow unless true, only shallow checks (url matching typically) should be done
|
||||||
* @return Boolean
|
* @return Boolean
|
||||||
*/
|
*/
|
||||||
static function supports($url, $deep = false);
|
static function supports(IOInterface $io, $url, $deep = false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,7 @@ class VcsRepository extends ArrayRepository
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($this->drivers as $driver) {
|
foreach ($this->drivers as $driver) {
|
||||||
if ($driver::supports($this->url)) {
|
if ($driver::supports($this->io, $this->url)) {
|
||||||
$driver = new $driver($this->url, $this->io);
|
$driver = new $driver($this->url, $this->io);
|
||||||
$driver->initialize();
|
$driver->initialize();
|
||||||
return $driver;
|
return $driver;
|
||||||
|
@ -67,7 +67,7 @@ class VcsRepository extends ArrayRepository
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($this->drivers as $driver) {
|
foreach ($this->drivers as $driver) {
|
||||||
if ($driver::supports($this->url, true)) {
|
if ($driver::supports($this->io, $this->url, true)) {
|
||||||
$driver = new $driver($this->url, $this->io);
|
$driver = new $driver($this->url, $this->io);
|
||||||
$driver->initialize();
|
$driver->initialize();
|
||||||
return $driver;
|
return $driver;
|
||||||
|
|
|
@ -68,9 +68,9 @@ class SvnDriverTest extends \PHPUnit_Framework_TestCase
|
||||||
public function testSupport($url, $assertion)
|
public function testSupport($url, $assertion)
|
||||||
{
|
{
|
||||||
if ($assertion === true) {
|
if ($assertion === true) {
|
||||||
$this->assertTrue(SvnDriver::supports($url));
|
$this->assertTrue(SvnDriver::supports($this->getMock('Composer\IO\IOInterface'), $url));
|
||||||
} else {
|
} else {
|
||||||
$this->assertFalse(SvnDriver::supports($url));
|
$this->assertFalse(SvnDriver::supports($this->getMock('Composer\IO\IOInterface'), $url));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue