flush
authorMichael Wallner <mike@php.net>
Tue, 12 May 2015 18:16:00 +0000 (20:16 +0200)
committerMichael Wallner <mike@php.net>
Tue, 12 May 2015 18:16:00 +0000 (20:16 +0200)
app/Controller/Github/Hook/Receive.php
app/Controller/Github/Repo.php
app/views/github/repo.phtml
app/views/navbar.phtml

index 48e10ae8e4effebab705591f2dac6c76b54781ad..62722edf99a75ce3c73fc08812864d1c747a606f 100644 (file)
@@ -80,9 +80,8 @@ 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);
+               $url = uri_template($release->upload_url, compact("name"));
                $this->github->createReleaseAsset($url, $asset, "application/phar", function($json) {
                        $response = $this->app->getResponse();
                        $response->setResponseCode(201);
@@ -91,7 +90,6 @@ class Receive implements Controller
        }
        
        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);
                $meta = [
index 32fab565a7794a3ccd4000e910cfaf4b2b87556c..ac2ce37d5916cebdb2a3fc68e8cb39f4c2fa1202 100644 (file)
@@ -32,6 +32,7 @@ class Repo extends Github
                settype($repo->tags, "object");
                $this->github->listHooks($repo->full_name, function($hooks) use($repo) {
                        $repo->hooks = $hooks;
+                       $this->app->getView()->addData(["hook" => $this->checkRepoHook($repo)]);
                });
                $this->github->listTags($repo->full_name, 1, $this->createTagsCallback($repo));
                $this->github->listReleases($repo->full_name, 1, $this->createReleasesCallback($repo));
index 80b5c8c1dc7021d1853d5cf2cefd327ac96848b7..ae72691120d0784e0c8d5057d59b1de8709386eb 100644 (file)
                                <p>Is the <code>pharext</code> hook enabled?</p>
                        </div>
                        <div class="col-md-4 text-center">
-                                       <?php if ($this->check($repo)) : ?>
+                                       <?php if (!empty($hook)) : ?>
                                        <span class="label label-info">YES</span>
                                        <?php else : ?>
                                        <span class="label label-warning">NO</span>
 
        <div class="col-md-6">
                <div class="row">
-                       <form method="post" action="<?= $baseUrl->mod("./github/repo/". $repo->full_name ."/hook/" . ($this->check($repo) ? "upd" : "add")) ?>">
-                               <div class="col-md-12">
+                       <form method="post" action="<?= $baseUrl->mod("./github/repo/". $repo->full_name ."/hook/" . (!empty($hook) ? "upd" : "add")) ?>">
+                               <div class="col-md-6">
+                                       <h4>PHARext Options:</h4>
+                                       <div class="checkbox">
+                                               <label for="hook-zend">
+                                                       <input id="hook-zend" type="checkbox" name="zend" value="1" <?= (!empty($hook) && !empty($hook->config->zend)) ? "checked":""?>>
+                                                       Mark as a ZendExtension.
+                                               </label>
+                                       </div>
+                                       <div class="checkbox <?= empty($repo->package_xml) ? "disabled text-muted":"" ?>">
+                                               <label for="hook-pecl">
+                                                       <input id="hook-pecl" type="checkbox" name="pecl" value="1" <?= (!empty($hook) && !empty($hook->config->pecl)) ? "checked":""?> <?= empty($repo->package_xml) ? "disabled":"" ?>>
+                                                       Use PECL package XML file.
+                                               </label>
+                                       </div>
+                               </div>
+                               <div class="col-md-6">
+                                       <h4>Hook Options:</h4>
                                                <div class="checkbox">
                                                        <label for="hook-tag">
-                                                               <input id="hook-tag" type="checkbox" name="tag" value="1" <?= ($hook = $this->check($repo)) && in_array("create", $hook->events) ? "checked":"" ?>>
+                                                               <input id="hook-tag" type="checkbox" name="tag" value="1" <?= (empty($hook) || in_array("create", $hook->events)) ? "checked":"" ?>>
                                                                Automatically create a release when I push a tag.
                                                        </label>
                                                </div>
                                                <div class="checkbox">
                                                        <label for="hook-release">
-                                                               <input id="hook-release" type="checkbox" name="release" value="1" <?= ($hook = $this->check($repo)) && in_array("release", $hook->events) ? "checked":"" ?>>
+                                                               <input id="hook-release" type="checkbox" name="release" value="1" <?= (empty($hook) || in_array("release", $hook->events)) ? "checked":"" ?>>
                                                                Automatically upload a PHARext package as an asset to a release.
                                                        </label>
                                                </div>
                                        </button>
                                </div>
                                <?php else : ?>
-                               <div class="col-md-12">
+                               <div class="col-md-6 col-md-offset-6">
                                        <button type="submit" class="btn btn-lg btn-block btn-success">
                                                <span class="octicon octicon-plug"></span>
                                                Enable Hook
index c7fbfb5f3a961ba58c62b88d672275a61d8f5c95..310ab533b469277573eb1ac25ec3ad081d5f85e3 100644 (file)
@@ -28,7 +28,8 @@
                                        </a>
                                        <ul class="dropdown-menu" role="menu">
                                                <?php foreach ($pages as $page) : ?>
-                                               <li><a href="<?= $baseUrl->mod("./pages/". rawurlencode($page)) ?>"><?= $this->e($page) ?></a></li>
+                                               <li><a href="<?= $baseUrl->mod("./pages/". rawurlencode($page)) ?>">
+                                                       <?= $this->e($page) ?></a></li>
                                                <?php endforeach; ?>
                                        </ul>
                                </li>