X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=app%2FController%2FGithub%2FRepo.php;h=bf1358a55400c035d216645784191d2ecef9c58e;hb=eb76e9bb9a39fe2725301f6cf6fc3cf29bbc4e00;hp=0c33a016c4cbc643bfeeaf7a049c47df5ee0627d;hpb=ebc0d017c8a24bd16ca1f4347b39b07ba4349135;p=pharext%2Fpharext.org diff --git a/app/Controller/Github/Repo.php b/app/Controller/Github/Repo.php index 0c33a01..bf1358a 100644 --- a/app/Controller/Github/Repo.php +++ b/app/Controller/Github/Repo.php @@ -8,24 +8,34 @@ class Repo extends Github { function __invoke(array $args = null) { extract($args); + $this->app->getView()->addData(compact("owner", "name")); if ($this->checkToken()) { - try { - $this->github->fetchRepo( - "$owner/$name", - [$this, "repoCallback"] - )->send(); - } catch (\app\Github\Exception $exception) { - $this->app->getView()->addData(compact("exception", "owner", "name")); + $this->github->readRepo( + "$owner/$name", + [$this, "repoCallback"] + )->send(); + + if (($modal = $this->app->getRequest()->getQuery("modal"))) { + $this->app->getView()->addData(compact("modal") + [ + "action" => $this->app->getRequest()->getQuery($modal) + ]); } + $this->app->display("github/repo"); } } - function repoCallback($repo, $links) { - $this->app->getView()->addData(compact("repo")); + function repoCallback($repo) { + $this->app->getView()->addData(compact("repo") + [ + "title" => "Github: {$repo->name}" + ]); settype($repo->tags, "object"); - $this->github->fetchTags($repo->full_name, 1, $this->createTagsCallback($repo)); - $this->github->fetchReleases($repo->full_name, 1, $this->createReleasesCallback($repo)); + $this->github->listHooks($repo->full_name, function($hooks) use($repo) { + $repo->hooks = $hooks; + }); + $this->github->listTags($repo->full_name, 1, $this->createTagsCallback($repo)); + $this->github->listReleases($repo->full_name, 1, $this->createReleasesCallback($repo)); + $this->github->readContents($repo->full_name, null, $this->createContentsCallback($repo)); } function createReleasesCallback($repo) { @@ -47,4 +57,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; + } + } + }; + } }