From: Michael Wallner Date: Sun, 10 May 2015 05:05:29 +0000 (+0200) Subject: prepare url X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=ff1d11c17adb6453aa50dfd6169317e077240eef;p=pharext%2Fpharext.org prepare url --- diff --git a/app/Controller/Github/Hook.php b/app/Controller/Github/Hook.php index 8161dde..bbfab2a 100644 --- a/app/Controller/Github/Hook.php +++ b/app/Controller/Github/Hook.php @@ -80,7 +80,10 @@ class Hook implements Controller private function uploadAssetForRelease($release, $repo) { $this->setTokenForUser($repo->owner->login); $asset = $this->createReleaseAsset($release, $repo); - $this->github->createReleaseAsset($release->upload_url, $asset, "application/phar", function($json) { + // 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); diff --git a/app/Github/Create/ReleaseAsset.php b/app/Github/Create/ReleaseAsset.php index 03d0d41..538273d 100644 --- a/app/Github/Create/ReleaseAsset.php +++ b/app/Github/Create/ReleaseAsset.php @@ -9,10 +9,8 @@ use http\Client\Request; class ReleaseAsset extends Create { function getRequest() { - // FIXME: use uri_template extension - $url = str_replace("{?name}", "?name=".urlencode(basename($this->args["asset"])), $this->args["url"]); $body = new \http\Message\Body(fopen($this->args["asset"], "rb")); - $request = new Request("POST", $url, [ + $request = new Request("POST", $this->args["url"], [ "Accept" => "application/vnd.github.v3+json", "Content-Type" => $this->args["type"], "Authorization" => "token ". $this->api->getToken()