X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=app%2FController%2FGithub%2FRelease.php;h=6743b19e7b480df968c21b7eeeb92db9e7fcc5a0;hb=303950054385d4c55cfef9a8828ee79420b7366e;hp=f0dd55f840c3498c255515f14e0ea39886a4a6eb;hpb=1097a4f83de3562c3518f31b168448c2c2ac0451;p=pharext%2Fpharext.org diff --git a/app/Controller/Github/Release.php b/app/Controller/Github/Release.php index f0dd55f..6743b19 100644 --- a/app/Controller/Github/Release.php +++ b/app/Controller/Github/Release.php @@ -5,42 +5,41 @@ namespace app\Controller\Github; use app\Controller\Github; use app\Github\API\Repos\RepoCallback; - class Release extends Github { function __invoke(array $args = null) { + if (!$this->checkToken()) { + return; + } + extract($args); - if ($this->checkToken()) { - list($repo) = $this->github->readRepo("$owner/$name", function($repo, $links = null) { - call_user_func(new RepoCallback($this->github), $repo, $links); - - $this->github->listReleases($repo->full_name, null, function($releases) use($repo) { - $config = $this->app->getRequest()->getForm(); - foreach ($releases as $r) { - if ($r->tag_name === $config->tag) { - $this->github->uploadAssetForRelease($repo, $r, $config, function() use($repo) { - $this->app->redirect($this->app->getBaseUrl()->mod("./github/" . $repo->full_name)); - }); - return; - } - } - - $this->github->createReleaseFromTag($repo, $tag, $config, function() use($repo) { - $this->app->redirect($this->app->getBaseUrl()->mod("./github/" . $repo->full_name)); - }); - }); - })->send(); - - $hook = $this->github->checkRepoHook($repo); - - $this->app->getView()->addData(compact("owner", "name", "repo", "hook")); - - if (($modal = $this->app->getRequest()->getQuery("modal"))) { - $action = $this->app->getRequest()->getQuery($modal); - $this->app->getView()->addData(compact("modal", "action")); + $this->github->readRepo("$owner/$name")->then( + new RepoCallback($this->github) + )->then(function($result) use(&$repo) { + list($repo,,,$releases) = $result; + $config = $this->app->getRequest()->getForm(); + + foreach ($releases as $release) { + if ($release->tag_name === $config["tag"]) { + return $this->github->uploadAssetForRelease($repo, $release, $config); + } } - $this->app->display("github/repo"); + return $this->github->createReleaseFromTag($repo, $config["tag"], $config); + })->done(function() use(&$repo) { + $this->app->redirect($this->app->getBaseUrl()->mod(":./github/repo/" . $repo->full_name)); + }); + + $this->github->drain(); + + $hook = $this->github->checkRepoHook($repo); + $this->app->getView()->addData(compact("owner", "name", "repo", "hook")); + + if (($modal = $this->app->getRequest()->getQuery("modal"))) { + $action = $this->app->getRequest()->getQuery($modal); + $this->app->getView()->addData(compact("modal", "action")); } + + $this->app->display("github/repo"); } }