소스 검색

workaround for gitlab installation with relative url

Signed-off-by: Minh-Quan TRAN <account@itscaro.me>
Minh-Quan TRAN 7 년 전
부모
커밋
007ca5ff6a
1개의 변경된 파일14개의 추가작업 그리고 0개의 파일을 삭제
  1. 14 0
      src/Composer/Util/RemoteFilesystem.php

+ 14 - 0
src/Composer/Util/RemoteFilesystem.php

@@ -195,6 +195,20 @@ class RemoteFilesystem
             $originUrl = 'github.com';
         }
 
+        // Gitlab can be installed in a non-root context. When downloading archives the originalUrl is the host without
+        // the relative path, so we look for the registered gitlab-domains that matching the host here
+        if (is_array($this->config->get('gitlab-domains'))
+            && false === strpos($originUrl, '/')
+            && !in_array($originUrl, $this->config->get('gitlab-domains'))) {
+            foreach($this->config->get('gitlab-domains') as $gitlabDomain) {
+                if (0 === strpos($gitlabDomain, $originUrl)) {
+                    $originUrl = $gitlabDomain;
+                    break;
+                }
+            }
+            unset($gitlabDomain);
+        }
+
         $this->scheme = parse_url($fileUrl, PHP_URL_SCHEME);
         $this->bytesMax = 0;
         $this->originUrl = $originUrl;