3 namespace app\Controller\Github
;
5 use app\Controller\Github
;
7 class Repo
extends Github
9 function __invoke(array $args = null) {
11 $this->app
->getView()->addData(compact("owner", "name"));
12 if ($this->checkToken()) {
13 $this->github
->readRepo(
15 [$this, "repoCallback"]
18 if (($modal = $this->app
->getRequest()->getQuery("modal"))) {
19 $this->app
->getView()->addData(compact("modal") +
[
20 "action" => $this->app
->getRequest()->getQuery($modal)
24 $this->app
->display("github/repo");
28 function repoCallback($repo) {
29 $this->app
->getView()->addData(compact("repo") +
[
30 "title" => "Github: {$repo->name}"
32 settype($repo->tags
, "object");
33 $this->github
->listHooks($repo->full_name
, function($hooks) use($repo) {
34 $repo->hooks
= $hooks;
35 $this->app
->getView()->addData(["hook" => $this->checkRepoHook($repo)]);
37 $this->github
->listTags($repo->full_name
, 1, $this->createTagsCallback($repo));
38 $this->github
->listReleases($repo->full_name
, 1, $this->createReleasesCallback($repo));
39 $this->github
->readContents($repo->full_name
, null, $this->createContentsCallback($repo));
42 function createReleasesCallback($repo) {
43 return function($releases, $links) use($repo) {
44 foreach ($releases as $release) {
45 $tag = $release->tag_name
;
46 settype($repo->tags
->$tag, "object");
47 $repo->tags
->$tag->release
= $release;
48 $this->github
->listReleaseAssets($repo->full_name
, $release->id
, function($assets) use($release) {
49 $release->assets
= $assets;
55 function createTagsCallback($repo) {
56 return function($tags, $links) use ($repo) {
57 foreach ($tags as $tag) {
59 settype($repo->tags
->$name, "object");
60 $repo->tags
->$name->tag
= $tag;
65 function createContentsCallback($repo) {
66 return function($tree) use($repo) {
67 foreach ($tree as $entry) {
68 if ($entry->type
!== "file" ||
$entry->size
<= 0) {
71 if ($entry->name
=== "config.m4" ||
fnmatch("config?.m4", $entry->name
)) {
72 $repo->config_m4
= $entry->name
;
73 } elseif ($entry->name
=== "package.xml" ||
$entry->name
=== "package2.xml") {
74 $repo->package_xml
= $entry->name
;
75 } elseif ($entry->name
=== "pharext_package.php") {
76 $repo->pharext_package_php
= $entry->name
;