v1-fix-add_commit_links.patch
text/x-diff
Filename: v1-fix-add_commit_links.patch
Type: text/x-diff
Part: 0
Message:
Re: PG 18 relnotes and RC1
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: unified
Series: patch v1
| File | + | − |
|---|---|---|
| src/tools/add_commit_links.pl | 37 | 28 |
diff --git a/src/tools/add_commit_links.pl b/src/tools/add_commit_links.pl
index 710a6492032..6dda0abcd29 100755
--- a/src/tools/add_commit_links.pl
+++ b/src/tools/add_commit_links.pl
@@ -20,12 +20,13 @@
#
# * File name contains the major version number preceded by a dash
# and followed by a period
-# * Commit text is generated by src/tools/git_changelog
-# * SGML comments around commit text start in the first column
-# * The commit item title ends with an attribution that ends with
-# a closing parentheses
-# * previously added URL link text is unmodified
-# * a "<para>" follows the commit item title
+# * Commit-details text is generated by src/tools/git_changelog
+# * SGML comment markers around commit details start in the first column
+# * Any previously-added URL links are unmodified
+#
+# URL links will be inserted just before the first "</para>" in each
+# release note item. They will be aligned to match the preceding line.
+# (Therefore, don't leave a blank line before that "</para>".)
#
# The major version number is used to select the commit hash for minor
# releases. An error will be generated if valid commits are found but
@@ -39,7 +40,7 @@ sub process_file
my $file = shift;
my $in_comment = 0;
- my $prev_line_ended_with_paren = 0;
+ my $in_item = 0;
my $prev_leading_space = '';
my $lineno = 0;
@@ -50,6 +51,8 @@ sub process_file
# Get major version number from the file name.
$file =~ m/-(\d+)\./;
my $major_version = $1;
+ die "file name $file is not in the expected format\n"
+ unless defined $major_version;
open(my $fh, '<', $file) || die "could not open file $file: $!\n";
open(my $tfh, '>', $tmpfile) || die "could not open file $tmpfile: $!\n";
@@ -58,7 +61,15 @@ sub process_file
{
$lineno++;
- $in_comment = 1 if (m/^<!--/);
+ if (m/^<!--/)
+ {
+ if ($in_item)
+ {
+ print "failed to find where to add links at line $lineno\n";
+ exit(1);
+ }
+ $in_comment = 1;
+ }
# skip over commit links because we will add them below
next
@@ -80,36 +91,34 @@ sub process_file
&& push(@hashes, $hash);
}
- if (!$in_comment && m{</para>})
+ if ($in_item && m{</para>})
{
- if (@hashes)
+ for my $hash (@hashes)
{
- if ($prev_line_ended_with_paren)
- {
- for my $hash (@hashes)
- {
- print $tfh
- "$prev_leading_space<ulink url=\"&commit_baseurl;$hash\">§</ulink>\n";
- }
- @hashes = ();
- }
- else
- {
- print
- "hashes found but no matching text found for placement on line $lineno\n";
- exit(1);
- }
+ print $tfh
+ "$prev_leading_space<ulink url=\"&commit_baseurl;$hash\">§</ulink>\n";
}
+ @hashes = ();
+ $in_item = 0;
}
print $tfh $_;
- $prev_line_ended_with_paren = m/\)\s*$/;
-
+ chomp; # don't allow newline in $prev_leading_space
m/^(\s*)/;
$prev_leading_space = $1;
- $in_comment = 0 if (m/^-->/);
+ if (m/^-->/)
+ {
+ $in_comment = 0;
+ $in_item = 1 if @hashes;
+ }
+ }
+
+ if ($in_item)
+ {
+ print "failed to find where to add links at line $lineno\n";
+ exit(1);
}
close($fh);