Merge pull request #4633 from jaapio/feature/gitlabInstallPath
Adds support for gitlab installed in subfolderpull/4656/head
commit
ddd85afd32
|
@ -62,6 +62,9 @@ class GitLabDriver extends VcsDriver
|
||||||
*/
|
*/
|
||||||
protected $gitDriver;
|
protected $gitDriver;
|
||||||
|
|
||||||
|
const URL_REGEX = '#^((https?)://(.*)/|git@([^:]+):)([^/]+)/(.+?)(?:\.git|/)?$#';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extracts information from the repository url.
|
* Extracts information from the repository url.
|
||||||
* SSH urls uses https by default.
|
* SSH urls uses https by default.
|
||||||
|
@ -70,7 +73,7 @@ class GitLabDriver extends VcsDriver
|
||||||
*/
|
*/
|
||||||
public function initialize()
|
public function initialize()
|
||||||
{
|
{
|
||||||
if (!preg_match('#^((https?)://([^/]+)/|git@([^:]+):)([^/]+)/(.+?)(?:\.git|/)?$#', $this->url, $match)) {
|
if (!preg_match(static::URL_REGEX, $this->url, $match)) {
|
||||||
throw new \InvalidArgumentException('The URL provided is invalid. It must be the HTTP URL of a GitLab project.');
|
throw new \InvalidArgumentException('The URL provided is invalid. It must be the HTTP URL of a GitLab project.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -343,7 +346,7 @@ class GitLabDriver extends VcsDriver
|
||||||
*/
|
*/
|
||||||
public static function supports(IOInterface $io, Config $config, $url, $deep = false)
|
public static function supports(IOInterface $io, Config $config, $url, $deep = false)
|
||||||
{
|
{
|
||||||
if (!preg_match('#^((https?)://([^/]+)/|git@([^:]+):)([^/]+)/(.+?)(?:\.git|/)?$#', $url, $match)) {
|
if (!preg_match(static::URL_REGEX, $url, $match)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,7 @@ class GitLabDriverTest extends \PHPUnit_Framework_TestCase
|
||||||
$this->config->merge(array(
|
$this->config->merge(array(
|
||||||
'config' => array(
|
'config' => array(
|
||||||
'home' => sys_get_temp_dir().'/composer-test',
|
'home' => sys_get_temp_dir().'/composer-test',
|
||||||
|
'gitlab-domains' => array('mycompany.com/gitlab', 'gitlab.com')
|
||||||
),
|
),
|
||||||
));
|
));
|
||||||
|
|
||||||
|
@ -215,6 +216,17 @@ JSON;
|
||||||
array('git@gitlab.com:foo/bar.git', extension_loaded('openssl')),
|
array('git@gitlab.com:foo/bar.git', extension_loaded('openssl')),
|
||||||
array('git@example.com:foo/bar.git', false),
|
array('git@example.com:foo/bar.git', false),
|
||||||
array('http://example.com/foo/bar', false),
|
array('http://example.com/foo/bar', false),
|
||||||
|
array('https://mycompany.com/gitlab/mygroup/myproject', true),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testGitlabSubDirectory()
|
||||||
|
{
|
||||||
|
$url = 'https://mycompany.com/gitlab/mygroup/myproject';
|
||||||
|
$apiUrl = 'https://mycompany.com/gitlab/api/v3/projects/mygroup%2Fmyproject';
|
||||||
|
|
||||||
|
$driver = new GitLabDriver(array('url' => $url), $this->io->reveal(), $this->config, $this->process->reveal(), $this->remoteFilesystem->reveal());
|
||||||
|
$driver->initialize();
|
||||||
|
$this->assertEquals($apiUrl, $driver->getApiUrl(), 'API URL is derived from the repository URL');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue