Adds support for gitlab install in subfolder

Since gitlab can be hosted on any url also subdirectories should be
supported. (e.g https://mycompany.com/gitlab).
This supports only http and https protocols since the gitlab api url
is derived from the package repository url. And the ssh protocol doesn't
support folders this way.
main
Jaapio 9 years ago
parent fbab2bfa17
commit b471440ea0

@ -70,7 +70,7 @@ class GitLabDriver extends VcsDriver
*/
public function initialize()
{
if (!preg_match('#^((https?)://([^/]+)/|git@([^:]+):)([^/]+)/(.+?)(?:\.git|/)?$#', $this->url, $match)) {
if (!preg_match('#^((https?)://([0-9a-zA-Z\./]+)/|git@([^:]+):)([^/]+)/(.+?)(?:\.git|/)?$#', $this->url, $match)) {
throw new \InvalidArgumentException('The URL provided is invalid. It must be the HTTP URL of a GitLab project.');
}

@ -217,4 +217,14 @@ JSON;
array('http://example.com/foo/bar', false),
);
}
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…
Cancel
Save