Commit:    576f18a1263d1b0c69557b49dd8925514c1992a7
Author:    Sara Golemon <[email protected]>         Tue, 9 Jul 2019 22:56:50 -0400
Parents:   aa1a61c557e93aefdce149f2fba0767e9fe76986
Branches:  master

Link:       
http://git.php.net/?p=web/php.git;a=commitdiff;h=576f18a1263d1b0c69557b49dd8925514c1992a7

Log:
Move recent release finding logic to branches.icn, clean up bumpRelease

Changed paths:
  M  bin/bumpRelease
  M  include/branches.inc
  M  include/version.inc


Diff:
diff --git a/bin/bumpRelease b/bin/bumpRelease
index f11812a..68fcd74 100755
--- a/bin/bumpRelease
+++ b/bin/bumpRelease
@@ -2,8 +2,9 @@
 <?php
 (PHP_SAPI === 'cli') or die("Please run this script using the cli sapi");
 
-require __DIR__ . "/../include/version.inc";
-require __DIR__ . "/../include/releases.inc";
+require_once __DIR__ . "/../include/branches.inc";
+require_once __DIR__ . "/../include/version.inc";
+require_once __DIR__ . "/../include/releases.inc";
 
 if ($_SERVER['argc'] < 1) {
        fwrite(STDERR, "Usage: {$_SERVER['argv'][0]} major_version [ 
minor_version ]\n");
@@ -12,43 +13,14 @@ if ($_SERVER['argc'] < 1) {
 
 $major = intval($_SERVER['argv'][1]);
 isset($RELEASES[$major]) or die("Unkown major version $major");
+$minor = isset($_SERVER['argv'][2]) ? intval($_SERVER['argv'][2]) : null;
 
-if (isset($_SERVER['argv'][2])) {
-       $minor = intval($_SERVER['argv'][2]);
-       $version_prefix = "{$major}.{$minor}.";
-       foreach ($RELEASES[$major] as $version => $info) {
-               if (strncmp($version, $version_prefix, strlen($version_prefix)) 
== 0) {
-                       // Bleed $version and $info into outer scope.
-                       break;
-               }
-       }
-       if (strncmp($version, $version_prefix, strlen($version_prefix))) {
-               fwrite(STDERR, "Unknown minor version $major.$minor\n");
-               exit(1);
-       }
-} else {
-       // Calling without a minor will just grab the most recent minor.
-       $version = key($RELEASES[$major]);
-       $info = current($RELEASES[$major]);
-}
+$version = get_current_release_for_branch($major, $minor);
+$info = $RELEASES[$major][$version] ?? null;
 
-if (!isset($info['date'])) {
-       // Derive date from source dates.
-       $info['date'] = null;
-       foreach ($info['source'] as $source) {
-               if ($info['date'] === null) {
-                       $info['date'] = $source['date'];
-                       continue;
-               }
-               if ($info['date'] !== $source['date']) {
-                       fwrite(STDERR, "Release has multiple differing dates in 
sources list. Unable to pick one.\n");
-                       exit(1);
-               }
-       }
-       if ($info['date'] === null) {
-               fwrite(STDERR, "Unable to determine release date.\n");
-               exit(1);
-       }
+if ($info === null) {
+       fwrite(STDERR, "Unable to find a current PHP release for 
{$major}.{$minor}\n");
+       exit(1);
 }
 
 $info["museum"] = false;
diff --git a/include/branches.inc b/include/branches.inc
index 361cb00..589404f 100644
--- a/include/branches.inc
+++ b/include/branches.inc
@@ -379,3 +379,26 @@ function version_array($version, $length = null)
 
        return $versionArray;
 }
+
+function get_current_release_for_branch(int $major, ?int $minor): ?string {
+       global $RELEASES, $OLDRELEASES;
+
+       $prefix = "{$major}.";
+       if ($minor !== null) {
+               $prefix .= "{$minor}.";
+       }
+
+       foreach (($RELEASES[$major] ?? []) as $version => $_) {
+               if (!strncmp($prefix, $version, strlen($prefix))) {
+                       return $version;
+               }
+       }
+
+       foreach (($OLDRELEASES[$major] ?? []) as $version => $_) {
+               if (!strncmp($prefix, $version, strlen($prefix))) {
+                       return $version;
+               }
+       }
+
+       return NULL;
+}
diff --git a/include/version.inc b/include/version.inc
index 0835b1b..eb2e106 100644
--- a/include/version.inc
+++ b/include/version.inc
@@ -29,7 +29,7 @@ $RELEASES = (function() {
     /* PHP 7.2 Release */
     $PHP_7_2_VERSION         = "7.2.20";
     $PHP_7_2_DATE            = "04 Jul 2019";
-    $PHP_7_2_TAGS            = ['']; // Set to ['security'] for security 
releases.
+    $PHP_7_2_TAGS            = []; // Set to ['security'] for security 
releases.
     $PHP_7_2_SHA256     = array(
         "tar.bz2"       => 
"9fb829e54e54c483ae8892d1db0f7d79115cc698f2f3591a8a5e58d9410dca84",
         "tar.gz"        => 
"d1dbf6f299514c9aa55b2995928b798b27c21811a0447f0688993cdf36be0749",
@@ -51,6 +51,7 @@ $RELEASES = (function() {
             $PHP_7_3_VERSION => array(
                 "announcement" => true,
                 "tags" => $PHP_7_3_TAGS,
+                "date" => $PHP_7_3_DATE,
                 "source" => array(
                     array(
                         "filename" => "php-$PHP_7_3_VERSION.tar.bz2",
@@ -75,6 +76,7 @@ $RELEASES = (function() {
             $PHP_7_2_VERSION => array(
                 "announcement" => true,
                 "tags" => $PHP_7_2_TAGS,
+                "date" => $PHP_7_2_DATE,
                 "source" => array(
                     array(
                         "filename" => "php-$PHP_7_2_VERSION.tar.bz2",
@@ -99,6 +101,7 @@ $RELEASES = (function() {
             $PHP_7_1_VERSION => array(
                 "announcement" => true,
                 "tags" => $PHP_7_1_TAGS,
+                "date" => $PHP_7_1_DATE,
                 "source" => array(
                     array(
                         "filename" => "php-$PHP_7_1_VERSION.tar.bz2",


--
PHP Webmaster List Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to