X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=app%2FController%2FGithub%2FHook%2FReceive.php;h=c53878c614123c602cad9aad19140821a03831f6;hb=36cfa28cf2dcee3422f0231f91c6692eb28e7824;hp=48e10ae8e4effebab705591f2dac6c76b54781ad;hpb=25b99959b9e66d00681092977c23b5df32ead5f4;p=pharext%2Fpharext.org diff --git a/app/Controller/Github/Hook/Receive.php b/app/Controller/Github/Hook/Receive.php index 48e10ae..c53878c 100644 --- a/app/Controller/Github/Hook/Receive.php +++ b/app/Controller/Github/Hook/Receive.php @@ -8,7 +8,7 @@ use app\Model\Accounts; use app\Web; use http\Params; use pharext\Task; -use pharext\SourceDir\Git; +use pharext\SourceDir; require_once __DIR__."/../../../../vendor/m6w6/pharext/src/pharext/Version.php"; @@ -79,21 +79,22 @@ class Receive implements Controller private function uploadAssetForRelease($release, $repo) { $this->setTokenForUser($repo->owner->login); - $asset = $this->createReleaseAsset($release, $repo); - // FIXME: use uri_template extension - $name = sprintf("%s-%s.ext.phar", $repo->name, $release->tag_name); - $url = str_replace("{?name}", "?name=$name", $release->upload_url); - $this->github->createReleaseAsset($url, $asset, "application/phar", function($json) { - $response = $this->app->getResponse(); - $response->setResponseCode(201); - $response->setHeader("Location", $json->url); + $this->github->listHooks($repo->full_name, function($hooks) use($release, $repo) { + $repo->hooks = $hooks; + $asset = $this->createReleaseAsset($release, $repo); + $name = sprintf("%s-%s.ext.phar", $repo->name, $release->tag_name); + $url = uri_template($release->upload_url, compact("name")); + $this->github->createReleaseAsset($url, $asset, "application/phar", function($json) { + $response = $this->app->getResponse(); + $response->setResponseCode(201); + $response->setHeader("Location", $json->url); + }); })->send(); } private function createReleaseAsset($release, $repo) { - define("STDERR", fopen("/var/log/apache2/php_errors.log", "a")); $source = (new Task\GitClone($repo->clone_url, $release->tag_name))->run(); - $iterator = new Git($source); + $iterator = new SourceDir\Git($source); $meta = [ "header" => sprintf("pharext v%s (c) Michael Wallner ", \pharext\VERSION), "version" => \pharext\VERSION,