fix pharext package name, release and metadata
authorMichael Wallner <mike@php.net>
Thu, 11 Jun 2015 08:38:32 +0000 (10:38 +0200)
committerMichael Wallner <mike@php.net>
Thu, 11 Jun 2015 08:38:32 +0000 (10:38 +0200)
app/Github/API.php
app/Pharext/Package.php

index 493984dbc037f76220c556e109fa6618d49335bb..3eea40d625defd7042bc1e3bb818348c5160d798 100644 (file)
@@ -264,7 +264,7 @@ class API
                                $repo->name, 
                                $config ?: (array) $this->checkRepoHook($repo)->config
                        );
-                       $name = sprintf("%s-%s.ext.phar", $repo->name, $release->tag_name);
+                       $name = $phar->build();
                        $url = uri_template($release->upload_url, compact("name"));
                        $promise = $this->createReleaseAsset($url, $phar, "application/phar");
                        if ($release->draft) {
index fb91d368b932ad2a53b13a7849acf8916da4dca5..342a103aa16e1fa828ef021efed6b3a51920b517 100644 (file)
@@ -8,21 +8,48 @@ use pharext\Task;
 
 class Package
 {
+       private $source;
        private $file;
+       private $name;
+       private $release;
+       private $zend;
 
        function __construct($git_url, $tag_name, $pkg_name, $options) {
                $dir = (new Task\GitClone($git_url, $tag_name))->run();
                $src = !empty($options["pecl"])
                        ? new SourceDir\Pecl($dir)
                        : new SourceDir\Git($dir);
+
+               /* setup defaults */
+               $this->release = $tag_name;
+               $this->name = $pkg_name;
+               $this->zend = !empty($options["zend"]);
+
+               /* override with package info from SourceDir */
+               foreach ($src->getPackageInfo() as $key => $val) {
+                       switch ($key) {
+                               case "name":
+                               case "release":
+                               case "zend":
+                                       $this->$key = $val;
+                                       break;
+                       }
+               }
+
+               $this->source = $src;
+       }
+
+       function build() {
                $meta = Metadata::all() + [
-                       "name" => $pkg_name,
-                       "release" => $tag_name,
-                       "license" => $src->getLicense(),
+                       "name" => $this->name,
+                       "release" => $this->release,
+                       "license" => $this->source->getLicense(),
                        "stub" => "pharext_installer.php",
-                       "type" => !empty($options["zend"]) ? "zend_extension" : "extension",
+                       "type" => $this->zend ? "zend_extension" : "extension",
                ];
-               $this->file = (new Task\PharBuild($src, $meta))->run();
+               $this->file = (new Task\PharBuild($this->source, $meta))->run();
+               
+               return sprintf("%s-%s.ext.phar", $this->name, $this->release);
        }
 
        function __toString() {
@@ -32,4 +59,12 @@ class Package
        function getFile() {
                return $this->file;
        }
+
+       function getName() {
+               return $this->name;
+       }
+
+       function getRelease() {
+               return $this->release;
+       }
 }