Skip to content

Commit 2116843

Browse files
committed
Improve Perl script which adds commit links to release notes
Reported-by: Andrew Dunstan Discussion: https://postgr.es/m/[email protected] Author: Andrew Dunstan Backpatch-through: 12
1 parent 4c9f9a8 commit 2116843

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

src/tools/add_commit_links.pl

+9-12
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,8 @@ sub process_file
5151
$file =~ m/-(\d+)\./;
5252
my $major_version = $1;
5353

54-
open(my $fh, '<', $file) || die "could not open file %s: $!\n", $file;
55-
open(my $tfh, '>', $tmpfile) || die "could not open file %s: $!\n",
56-
$tmpfile;
54+
open(my $fh, '<', $file) || die "could not open file $file: $!\n";
55+
open(my $tfh, '>', $tmpfile) || die "could not open file $tmpfile: $!\n";
5756

5857
while (<$fh>)
5958
{
@@ -64,9 +63,9 @@ sub process_file
6463
# skip over commit links because we will add them below
6564
next
6665
if (!$in_comment &&
67-
m{^\s*<ulink url="&commit_baseurl;[\da-f]+">&sect;</ulink>\s*$});
66+
m{^\s*<ulink url="&commit_baseurl;[[:xdigit:]]+">&sect;</ulink>\s*$});
6867

69-
if ($in_comment && m/\[([\da-f]+)\]/)
68+
if ($in_comment && m/\[([[:xdigit:]]+)\]/)
7069
{
7170
my $hash = $1;
7271

@@ -88,23 +87,21 @@ sub process_file
8887
{
8988
for my $hash (@hashes)
9089
{
91-
print({$tfh}
92-
"$prev_leading_space<ulink url=\"&commit_baseurl;$hash\">&sect;</ulink>\n"
93-
);
90+
print $tfh
91+
"$prev_leading_space<ulink url=\"&commit_baseurl;$hash\">&sect;</ulink>\n";
9492
}
9593
@hashes = ();
9694
}
9795
else
9896
{
99-
printf(
100-
"hashes found but no matching text found for placement on line %s\n",
101-
$lineno);
97+
print
98+
"hashes found but no matching text found for placement on line $lineno\n";
10299
exit(1);
103100
}
104101
}
105102
}
106103

107-
print({$tfh} $_);
104+
print $tfh $_;
108105

109106
$prev_line_ended_with_paren = m/\)\s*$/;
110107

0 commit comments

Comments
 (0)