1#! /usr/bin/env perl -pi
2
3BEGIN {
4    our $count = 1;              # Only the first one
5    our $RELEASE = $ENV{RELEASE};
6    our $RELEASE_TEXT = $ENV{RELEASE_TEXT};
7    our $PREV_RELEASE_DATE = $ENV{PREV_RELEASE_DATE} || 'xx XXX xxxx';
8    our $PREV_RELEASE_TEXT = $ENV{PREV_RELEASE_TEXT};
9
10    $RELEASE =~ s/-dev//;
11}
12
13if (/^### Changes between (\S+) and (\S+) \[xx XXX xxxx\]/
14    && $count-- > 0) {
15    my $v1 = $1;
16    my $v2 = $PREV_RELEASE_TEXT || $2;
17
18    # If this is a pre-release, we do nothing
19    if ($RELEASE !~ /^\d+\.\d+\.\d+-(?:alpha|beta)/) {
20        $_ = <<_____
21### Changes between $v2 and $RELEASE_TEXT [xx XXX xxxx]
22
23 * none yet
24
25### Changes between $v1 and $v2 [$PREV_RELEASE_DATE]
26_____
27    }
28}
29