summaryrefslogtreecommitdiff
path: root/maint/changelog-syntax-fiddle
blob: 0a56d0f5c77718577740155f68346399cf686fdf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env -S perl -wp
#
# This terrible perl script helps convert the easy-to-edit
#
#   - Changelog item.
#     !1234
#     #6789
#     TROVE-2024-001
#
# into our canonical CHANGELOG.md style
#
#   - Changelog item.
#     ([!1234], [#6789], [TROVE-2024-001])
#
# You pipe the new bit of the changelog through it manually.
# You'll probably need to edit it before and after.

use strict;

our @links;

s{[ \t]*$}{};

my $linky = qr{[!#]\d{3,}|TROVE-\d+-\d+};

sub write_out_links () {
  if (@links) {
    print "  (";
    print join ', ', @links;
    print ")\n";
    @links = ();
  }
}

if (m{^  ($linky)$}) {
  push @links, "[$1]";
  $_ = '';
} else {
  write_out_links();
}

END { write_out_links(); }