Explorar el Código

Merge branch 'master' into 2.0

Jordi Boggiano hace 5 años
padre
commit
e15f7d6bb7

+ 1 - 1
src/Composer/Autoload/AutoloadGenerator.php

@@ -336,7 +336,7 @@ EOF;
         return 0;
     }
 
-    private function addClassMapCode($filesystem, $basePath, $vendorPath, $dir, $blacklist = null, $namespaceFilter = null, $autoloadType = null, array $classMap, array &$ambiguousClasses)
+    private function addClassMapCode($filesystem, $basePath, $vendorPath, $dir, $blacklist, $namespaceFilter, $autoloadType, array $classMap, array &$ambiguousClasses)
     {
         foreach ($this->generateClassMap($dir, $blacklist, $namespaceFilter, $autoloadType) as $class => $path) {
             $pathCode = $this->getPathCode($filesystem, $basePath, $vendorPath, $path).",\n";

+ 1 - 1
src/Composer/Installer.php

@@ -323,7 +323,7 @@ class Installer
                     1 === $fundingCount ? '' : 's',
                     1 === $fundingCount ? 'is' : 'are'
                 ),
-                '<info>Use the composer fund command to find out more!</info>',
+                '<info>Use the `composer fund` command to find out more!</info>',
             ));
         }
 

+ 11 - 0
src/Composer/Repository/PathRepository.php

@@ -134,6 +134,17 @@ class PathRepository extends ArrayRepository implements ConfigurableRepositoryIn
         $urlMatches = $this->getUrlMatches();
 
         if (empty($urlMatches)) {
+            if (preg_match('{[*{}]}', $this->url)) {
+                $url = $this->url;
+                while (preg_match('{[*{}]}', $url)) {
+                    $url = dirname($url);
+                }
+                // the parent directory before any wildcard exists, so we assume it is correctly configured but simply empty
+                if (is_dir($url)) {
+                    return;
+                }
+            }
+
             throw new \RuntimeException('The `url` supplied for the path (' . $this->url . ') repository does not exist');
         }
 

+ 23 - 0
src/Composer/Repository/Vcs/GitLabDriver.php

@@ -429,6 +429,29 @@ class GitLabDriver extends VcsDriver
             if ($fetchingRepoData) {
                 $json = $response->decodeJson();
 
+                // Accessing the API with a token with Guest (10) access will return
+                // more data than unauthenticated access but no default_branch data
+                // accessing files via the API will then also fail
+                if (!isset($json['default_branch']) && isset($json['permissions'])) {
+                    $this->isPrivate = $json['visibility'] !== 'public';
+
+                    $moreThanGuestAccess = false;
+                    // Check both access levels (e.g. project, group)
+                    // - value will be null if no access is set
+                    // - value will be array with key access_level if set
+                    foreach ($json['permissions'] as $permission) {
+                        if ($permission && $permission['access_level'] > 10) {
+                            $moreThanGuestAccess = true;
+                        }
+                    }
+
+                    if (!$moreThanGuestAccess) {
+                        $this->io->writeError('<warning>GitLab token with Guest only access detected</warning>');
+
+                        return $this->attemptCloneFallback(); 
+                    }
+                }
+
                 // force auth as the unauthenticated version of the API is broken
                 if (!isset($json['default_branch'])) {
                     if (!empty($json['id'])) {

+ 1 - 1
tests/Composer/Test/Fixtures/installer/install-funding-notice.test

@@ -53,7 +53,7 @@ Installing dependencies from lock file (including require-dev)
 Package operations: 3 installs, 0 updates, 0 removals
 Generating autoload files
 2 packages you are using are looking for funding.
-Use the composer fund command to find out more!
+Use the `composer fund` command to find out more!
 --EXPECT--
 Installing b/b (1.0.0)
 Installing d/d (1.0.0)