prepare url
authorMichael Wallner <mike@php.net>
Sun, 10 May 2015 05:05:29 +0000 (07:05 +0200)
committerMichael Wallner <mike@php.net>
Sun, 10 May 2015 05:05:29 +0000 (07:05 +0200)
app/Controller/Github/Hook.php
app/Github/Create/ReleaseAsset.php

index 8161dde9b83ded19f65c8a1b629dcbd5930d470c..bbfab2a8db935df92e6e9e85d42b51983a4b76c7 100644 (file)
@@ -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);
index 03d0d415ea0d86d65a69865e2ff040933bd72491..538273d2258ceb504361209186d5d651e103be17 100644 (file)
@@ -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()