浏览代码

Add secure-http:false option to disable the https default of gitlab driver when using ssh urls, fixes #5254

Jordi Boggiano 9 年之前
父节点
当前提交
40df5dddee
共有 1 个文件被更改,包括 4 次插入3 次删除
  1. 4 3
      src/Composer/Repository/Vcs/GitLabDriver.php

+ 4 - 3
src/Composer/Repository/Vcs/GitLabDriver.php

@@ -66,7 +66,8 @@ class GitLabDriver extends VcsDriver
 
     /**
      * Extracts information from the repository url.
-     * SSH urls uses https by default.
+     *
+     * SSH urls use https by default. Set "secure-http": false on the repository config to use http instead.
      *
      * {@inheritDoc}
      */
@@ -76,7 +77,7 @@ class GitLabDriver extends VcsDriver
             throw new \InvalidArgumentException('The URL provided is invalid. It must be the HTTP URL of a GitLab project.');
         }
 
-        $this->scheme = !empty($match['scheme']) ? $match['scheme'] : 'https';
+        $this->scheme = !empty($match['scheme']) ? $match['scheme'] : (isset($this->repoConfig['secure-http']) && $this->repoConfig['secure-http'] === false ? 'http' : 'https');
         $this->originUrl = !empty($match['domain']) ? $match['domain'] : $match['domain2'];
         $this->owner = $match['owner'];
         $this->repository = preg_replace('#(\.git)$#', '', $match['repo']);
@@ -359,7 +360,7 @@ class GitLabDriver extends VcsDriver
             return false;
         }
 
-        $scheme = !empty($match['scheme']) ? $match['scheme'] : 'https';
+        $scheme = !empty($match['scheme']) ? $match['scheme'] : null;
         $originUrl = !empty($match['domain']) ? $match['domain'] : $match['domain2'];
 
         if (!in_array($originUrl, (array) $config->get('gitlab-domains'))) {