repo checks
[pharext/pharext.org] / app / Controller / Github / Repo.php
index 0c33a016c4cbc643bfeeaf7a049c47df5ee0627d..02ab7a94bd1e4202bb6a82b745969a115a68c370 100644 (file)
@@ -24,8 +24,12 @@ class Repo extends Github
        function repoCallback($repo, $links) {
                $this->app->getView()->addData(compact("repo"));
                settype($repo->tags, "object");
+               $this->github->fetchHooks($repo->full_name, function($hooks) use($repo) {
+                       $repo->hooks = $hooks;
+               });
                $this->github->fetchTags($repo->full_name, 1, $this->createTagsCallback($repo));
                $this->github->fetchReleases($repo->full_name, 1, $this->createReleasesCallback($repo));
+               $this->github->fetchContents($repo->full_name, null, $this->createContentsCallback($repo));
        }
 
        function createReleasesCallback($repo) {
@@ -47,4 +51,21 @@ class Repo extends Github
                        }
                };
        }
+       
+       function createContentsCallback($repo) {
+               return function($tree) use($repo) {
+                       foreach ($tree as $entry) {
+                               if ($entry->type !== "file" || $entry->size <= 0) {
+                                       continue;
+                               }
+                               if ($entry->name === "config.m4" || fnmatch("config?.m4", $entry->name)) {
+                                       $repo->config_m4 = $entry->name;
+                               } elseif ($entry->name === "package.xml" || $entry->name === "package2.xml") {
+                                       $repo->package_xml = $entry->name;
+                               } elseif ($entry->name === "pharext_package.php") {
+                                       $repo->pharext_package_php = $entry->name;
+                               }
+                       }
+               };
+       }
 }