2ee935d3cf47035eaa8477017e6678582047bdc8
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"));
20 $this->app
->display("github/repo");
24 function repoCallback($repo, $links) {
25 $this->app
->getView()->addData(compact("repo") +
[
26 "title" => "Github: {$repo->name}"
28 settype($repo->tags
, "object");
29 $this->github
->fetchHooks($repo->full_name
, function($hooks) use($repo) {
30 $repo->hooks
= $hooks;
32 $this->github
->fetchTags($repo->full_name
, 1, $this->createTagsCallback($repo));
33 $this->github
->fetchReleases($repo->full_name
, 1, $this->createReleasesCallback($repo));
34 $this->github
->fetchContents($repo->full_name
, null, $this->createContentsCallback($repo));
37 function createReleasesCallback($repo) {
38 return function($releases, $links) use($repo) {
39 foreach ($releases as $release) {
40 $tag = $release->tag_name
;
41 settype($repo->tags
->$tag, "object");
42 $repo->tags
->$tag->release
= $release;
47 function createTagsCallback($repo) {
48 return function($tags, $links) use ($repo) {
49 foreach ($tags as $tag) {
51 settype($repo->tags
->$name, "object");
52 $repo->tags
->$name->tag
= $tag;
57 function createContentsCallback($repo) {
58 return function($tree) use($repo) {
59 foreach ($tree as $entry) {
60 if ($entry->type
!== "file" ||
$entry->size
<= 0) {
63 if ($entry->name
=== "config.m4" ||
fnmatch("config?.m4", $entry->name
)) {
64 $repo->config_m4
= $entry->name
;
65 } elseif ($entry->name
=== "package.xml" ||
$entry->name
=== "package2.xml") {
66 $repo->package_xml
= $entry->name
;
67 } elseif ($entry->name
=== "pharext_package.php") {
68 $repo->pharext_package_php
= $entry->name
;