Selaa lähdekoodia

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.
Jaapio 10 vuotta sitten
vanhempi
commit
b471440ea0

+ 1 - 1
src/Composer/Repository/Vcs/GitLabDriver.php

@@ -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.');
         }
 

+ 10 - 0
tests/Composer/Test/Repository/Vcs/GitLabDriverTest.php

@@ -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');
+    }
 }