2 # Copyright (c) Olly Betts 2010,2011,2012
4 # Permission is hereby granted, free of charge, to any person obtaining a copy
5 # of this software and associated documentation files (the "Software"), to
6 # deal in the Software without restriction, including without limitation the
7 # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 # sell copies of the Software, and to permit persons to whom the Software is
9 # furnished to do so, subject to the following conditions:
11 # The above copyright notice and this permission notice shall be included in
12 # all copies or substantial portions of the Software.
14 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
31 my $date = strftime
("%Y-%m-%d", gmtime());
32 open NEWS
, '<', 'NEWS' or die "Can't find 'NEWS' in current directory: $!\n";
35 if ($news =~ /^(?:up *to:)? *(\d+|[[:xdigit:]]{7,})\b/i) {
36 # Partly updated already.
42 # Discard that line...
44 } elsif ($news =~ /^(?:Changes in|\S+) (\d[\d\.]*\.)(\d+) \(/) {
45 # No updates since the last release.
46 my $last_release = "$1$2";
47 $new_version = $1.($2+1);
48 print "Finding changes since release '$last_release'.\n";
50 open SVNINFO
, "svn info|" or die $!;
53 if (s/^Repository Root: //) {
59 if (!defined $svnroot) {
60 die "svn info didn't tell us the repo root!\n";
63 open SVNLOG
, "svn log --limit=1 \Q$svnroot\E/tags/\Q$last_release\E|" or die $!;
65 if (!defined $line || $line !~ /^-+$/) {
66 $last_release =~ y/./_/;
67 open SVNLOG
, "svn log --limit=1 \Q$svnroot\E/tags/v\Q$last_release\E|" or die $!;
69 if (!defined $line || $line !~ /^-+$/) {
70 die "Unexpected output from svn log.\n";
74 if ($line !~ /^r(\d+) \|/) {
75 die "Unexpected output from svn log.\n";
80 $rev1 = $last_release;
83 die "Can't find revision in NEWS\n";
87 open BLAME
, "svn blame -r$rev1:HEAD ChangeLog 2>/dev/null|" or die $!;
89 open BLAME
, "git blame $rev1.. ChangeLog 2>/dev/null|" or die $!;
92 open NEWSTMP
, '>', 'NEWS~' or die $!;
97 print NEWSTMP
if $lines == 0;
99 if (!s/^( *(\d+) +(\S+) )//) {
112 if (s/^([[:xdigit:]]+.*?) +\d+\) //) {
130 print "No ChangeLog entries since the last update to NEWS.\n";
135 if (defined $new_version) {
136 if (open NEWSSKEL
, '<', 'NEWS.SKELETON') {
138 s/\@VERSION\@/$new_version/g;
145 print NEWSTMP
$news if defined $news;
147 if (!defined $new_version) {
148 if (s/^([A-Za-z][-\w]* (\d+(?:\.\d+)+) \()\d{4}-\d\d-\d\d(\):)$/$1$date$3/) {
155 close NEWSTMP
or die $!;
156 rename 'NEWS~', 'NEWS' or die $!;