xaav 13 年之前
父節點
當前提交
fbd181e1f0
共有 1 個文件被更改,包括 4 次插入25 次删除
  1. 4 25
      src/Packagist/WebBundle/Repository/Repository/GitRepository.php

+ 4 - 25
src/Packagist/WebBundle/Repository/Repository/GitRepository.php

@@ -14,27 +14,11 @@ class GitRepository implements RepositoryInterface
         $this->repository = $match[2];
     }
 
-    /**
-     * @deprecated
-     */
-    protected function getComposerFile($hash)
-    {
-        return json_decode(file_get_contents('https://raw.github.com/'.$this->owner.'/'.$this->repository.'/'.$hash.'/composer.json'), true);
-    }
-
     protected function getRepoData()
     {
         return json_decode(file_get_contents('http://github.com/api/v2/json/repos/show/'.$this->owner.'/'.$this->repository), true);
     }
 
-    /**
-     * @deprecated
-     */
-    protected function getTagsData()
-    {
-        return json_decode(file_get_contents('http://github.com/api/v2/json/repos/show/'.$this->owner.'/'.$this->repository.'/tags'), true);
-    }
-
     public function getSource()
     {
         return array('type' => 'git', 'url' => $this->getUrl());
@@ -65,12 +49,13 @@ class GitRepository implements RepositoryInterface
 
         $files = array();
 
-        $tagsData = $this->getTagsData();
+        $tagsData = json_decode(file_get_contents('http://github.com/api/v2/json/repos/show/'.$this->owner.'/'.$this->repository.'/tags'), true);
         foreach ($tagsData['tags'] as $tag => $hash) {
-            if($file = $this->getComposerFile($hash)) {
+            if($file = json_decode(file_get_contents('https://raw.github.com/'.$this->owner.'/'.$this->repository.'/'.$hash.'/composer.json'), true)) {
 
                 if(!isset($file['time'])) {
-                    $file['time'] = $this->getTime($tag);
+                    $commit = json_decode(file_get_contents('http://github.com/api/v2/json/commits/show/'.$this->owner.'/'.$this->repository.'/'.$tag), true);
+                    $file['time'] = $commit['commit']['committed_date'];
                 }
 
                 $files[$tag] = $file;
@@ -79,10 +64,4 @@ class GitRepository implements RepositoryInterface
 
         return $files;
     }
-
-    protected function getTime($uniqid)
-    {
-        $commit = json_decode(file_get_contents('http://github.com/api/v2/json/commits/show/'.$this->owner.'/'.$this->repository.'/'.$uniqid), true);
-        return $commit['commit']['committed_date'];
-    }
 }