com web/php: Add direct writing to bin/news2html: bin/news2html
| From: | Sara Golemon | Date: | Wed, 05 Jun 2019 18:25:33 +0000 |
| Subject: | com web/php: Add direct writing to bin/news2html: bin/news2html | ||
| Groups: | php.webmaster | ||
| Request: | Send a blank email to php-webmaster+get-28150@lists.php.net to get a copy of this message | ||
Commit: 498292a99c1c58f3e2d289d874b5cab5c97f5e2c
Author: Sara Golemon <pollita@php.net> Wed, 5 Jun 2019 14:25:33 -0400
Parents: d8e2012418740e9e26f576e25b1f2463739abea5
Branches: master
Link: http://git.php.net/?p=web/php.git;a=commitdiff;h=498292a99c1c58f3e2d289d874b5cab5c97f5e2c
Log:
Add direct writing to bin/news2html
Changed paths:
M bin/news2html
Diff:
diff --git a/bin/news2html b/bin/news2html
index 5dc8165..59f497e 100755
--- a/bin/news2html
+++ b/bin/news2html
@@ -6,11 +6,12 @@ PHP_SAPI == 'cli' or die("Please run this script using the cli
sapi");
$cmd = array_shift($_SERVER['argv']);
if (count($_SERVER['argv']) < 2) {
- echo "Use: $cmd /path/to/php-5.4.16/NEWS 5.4.16\n";
+ echo "Use: $cmd /path/to/php-5.4.16/NEWS 5.4.16 [path/to/ChangeLog.php]\n";
exit(1);
}
$news_file = array_shift($_SERVER['argv']);
$version = array_shift($_SERVER['argv']);
+$changelog = @array_shift($_SERVER['argv']);
// find NEWS entry
$fp = fopen($news_file, "r");
@@ -50,6 +51,7 @@ while(($ln = fgets($fp)) !== false) {
}
}
+if ($changelog) { ob_start(); }
echo <<<HEAD
<section class="version" id="$version"><!-- {{{ $version -->
@@ -76,3 +78,29 @@ foreach($entries as $module => $items) {
echo "</ul></li>\n";
}
echo "</ul>\n<!-- }}} --></section>\n\n";
+
+if ($changelog) {
+ $contents = ob_get_contents();
+ ob_end_clean();
+
+ $log = file_get_contents($changelog);
+ if (empty($log)) {
+ fprintf(STDERR, "Unable to read $changelog\n");
+ exit(1);
+ }
+
+ $parts = explode('.', $version, 3);
+ if (count($parts) < 2) {
+ fprintf(STDERR, "Unable to parse branch from $version\n");
+ exit(1);
+ }
+
+ $tag = "<a name=\"PHP_{$parts[0]}_{$parts[1]}\"></a>";
+ if (strpos($log, $tag) === false) {
+ fprintf(STDERR, "Unable to find branch tag in ChangeLog\n");
+ exit(1);
+ }
+
+ $log = str_replace($tag, "$tag\n\n$contents", $log);
+ file_put_contents($changelog, $log);
+}