瀏覽代碼

Moved time method to GitRepository

xaav 13 年之前
父節點
當前提交
660ed8205c

+ 0 - 6
src/Packagist/WebBundle/Command/UpdatePackagesCommand.php

@@ -101,12 +101,6 @@ EOF
                         }
                     }
 
-                    //TODO: This should be done in getAllComoserFiles()
-                    // fetch date from the commit if not specified
-                    if (!isset($data['time'])) {
-                        $data['time'] = $repo->getTime($uniqid);
-                    }
-
                     $version->setPackage($package);
                     $version->setUpdatedAt(new \DateTime);
                     $version->setReleasedAt(new \DateTime($data['time']));

+ 6 - 1
src/Packagist/WebBundle/Repository/Repository/GitRepository.php

@@ -68,6 +68,11 @@ class GitRepository implements RepositoryInterface
         $tagsData = $this->getTagsData();
         foreach ($tagsData['tags'] as $tag => $hash) {
             if($file = $this->getComposerFile($hash)) {
+
+                if(!isset($file['time'])) {
+                    $file['time'] = $this->getTime($tag);
+                }
+
                 $files[$tag] = $file;
             }
         }
@@ -75,7 +80,7 @@ class GitRepository implements RepositoryInterface
         return $files;
     }
 
-    public function getTime($uniqid)
+    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'];