Sfoglia il codice sorgente

Add support for new GitHub API

Jordi Boggiano 13 anni fa
parent
commit
7a28a2d83a
1 ha cambiato i file con 11 aggiunte e 5 eliminazioni
  1. 11 5
      src/Composer/Repository/Vcs/GitHubDriver.php

+ 11 - 5
src/Composer/Repository/Vcs/GitHubDriver.php

@@ -33,14 +33,14 @@ class GitHubDriver extends VcsDriver
 
     /**
      * Git Driver
-     * 
+     *
      * @var GitDriver
      */
     protected $gitDriver;
 
     /**
      * Constructor
-     * 
+     *
      * @param string $url
      * @param IOInterface $io
      * @param ProcessExecutor $process
@@ -193,7 +193,7 @@ class GitHubDriver extends VcsDriver
 
     /**
      * Generate an SSH URL
-     * 
+     *
      * @return string
      */
     protected function generateSshUrl()
@@ -203,7 +203,7 @@ class GitHubDriver extends VcsDriver
 
     /**
      * Fetch root identifier from GitHub
-     * 
+     *
      * @throws TransportException
      */
     protected function fetchRootIdentifier()
@@ -216,7 +216,13 @@ class GitHubDriver extends VcsDriver
             }
             try {
                 $repoData = JsonFile::parseJson($this->getContents($repoDataUrl));
-                $this->rootIdentifier = $repoData['master_branch'] ?: 'master';
+                if (isset($repoData['default_branch'])) {
+                    $this->rootIdentifier = $repoData['default_branch'];
+                } elseif (isset($repoData['master_branch'])) {
+                    $this->rootIdentifier = $repoData['master_branch'];
+                } else {
+                    $this->rootIdentifier = 'master';
+                }
             } catch (TransportException $e) {
                 switch($e->getCode()) {
                     case 401: