Browse Source

Fix bug when readme is missing

Jordi Boggiano 9 years ago
parent
commit
8231a2cfe6
1 changed files with 10 additions and 2 deletions
  1. 10 2
      src/Packagist/WebBundle/Package/Updater.php

+ 10 - 2
src/Packagist/WebBundle/Package/Updater.php

@@ -167,7 +167,7 @@ class Updater
             }
         }
 
-        if (preg_match('{^(?:git@|https?://)github.com[:/]([^/]+)/(.+?)(?:\.git|/)?$}i', $package->getRepository(), $match)) {
+        if (preg_match('{^(?:git://|git@|https?://)github.com[:/]([^/]+)/(.+?)(?:\.git|/)?$}i', $package->getRepository(), $match)) {
             $this->updateGitHubInfo($rfs, $package, $match[1], $match[2]);
         }
 
@@ -396,10 +396,18 @@ class Updater
 
         try {
             $repoData = JsonFile::parseJson($rfs->getContents('github.com', $baseApiUrl, false), $baseApiUrl);
+        } catch (\Exception $e) {
+            return;
+        }
+
+        try {
             $opts = ['http' => ['header' => ['Accept: application/vnd.github.v3.html']]];
             $readme = $rfs->getContents('github.com', $baseApiUrl.'/readme', false, $opts);
         } catch (\Exception $e) {
-            return;
+            if (!$e instanceof \Composer\Downloader\TransportException || $e->getCode() !== 404) {
+                return;
+            }
+            // 404s just mean no readme present so we proceed with the rest
         }
 
         if (!empty($readme)) {