3 namespace app\Controller\Github
;
5 use app\Controller\Github
;
7 class Repo
extends Github
9 function __invoke(array $args = null) {
11 if ($this->checkToken()) {
13 $this->github
->fetchRepo(
15 [$this, "repoCallback"]
17 } catch (\app\Github\Exception
$exception) {
18 $this->app
->getView()->addData(compact("exception", "owner", "name"));
21 if (($modal = $this->app
->getRequest()->getQuery("modal"))) {
22 $this->app
->getView()->addData(compact("modal") +
[
23 "action" => $this->app
->getRequest()->getQuery($modal)
27 $this->app
->display("github/repo");
31 function repoCallback($repo, $links) {
32 $this->app
->getView()->addData(compact("repo") +
[
33 "title" => "Github: {$repo->name}"
35 settype($repo->tags
, "object");
36 $this->github
->fetchHooks($repo->full_name
, function($hooks) use($repo) {
37 $repo->hooks
= $hooks;
39 $this->github
->fetchTags($repo->full_name
, 1, $this->createTagsCallback($repo));
40 $this->github
->fetchReleases($repo->full_name
, 1, $this->createReleasesCallback($repo));
41 $this->github
->fetchContents($repo->full_name
, null, $this->createContentsCallback($repo));
44 function createReleasesCallback($repo) {
45 return function($releases, $links) use($repo) {
46 foreach ($releases as $release) {
47 $tag = $release->tag_name
;
48 settype($repo->tags
->$tag, "object");
49 $repo->tags
->$tag->release
= $release;
54 function createTagsCallback($repo) {
55 return function($tags, $links) use ($repo) {
56 foreach ($tags as $tag) {
58 settype($repo->tags
->$name, "object");
59 $repo->tags
->$name->tag
= $tag;
64 function createContentsCallback($repo) {
65 return function($tree) use($repo) {
66 foreach ($tree as $entry) {
67 if ($entry->type
!== "file" ||
$entry->size
<= 0) {
70 if ($entry->name
=== "config.m4" ||
fnmatch("config?.m4", $entry->name
)) {
71 $repo->config_m4
= $entry->name
;
72 } elseif ($entry->name
=== "package.xml" ||
$entry->name
=== "package2.xml") {
73 $repo->package_xml
= $entry->name
;
74 } elseif ($entry->name
=== "pharext_package.php") {
75 $repo->pharext_package_php
= $entry->name
;