Debian Codegraph @

scripts/get_release_notes.pl

raw
1 #!/usr/bin/perl
2 #
3 # @(#) Perl script to extract release notes from src/splash.f90
4 #
5 my $start = 0;
6 my $out = "";
7 my $do_all = 0;
8 my $file='src/splash.f90'; # default filename if no arguments given
9 # handle command line arguments
10 if ($#ARGV==0) {
11 # can give ./get_release_notes all [with default file name]
12 # or ./get_release_notes src/splash.f90 [to specify file name]
13 if ( @ARGV[0] =~ m/all/ ) {
14 $do_all = 1;
15 } else {
16 $file = @ARGV[0];
17 };
18 } elsif ($#ARGV==1) {
19 # or ./get_release_notes src/splash.f90 all [to specify file name AND all option]
20 $file = @ARGV[0];
21 if ( @ARGV[1] =~ m/all/ ) {
22 $do_all = 1;
23 };
24 } elsif ($#ARGV > 1) {
25 die "Usage: $0 src/file.f90 [all] \n";
26 }
27 my @eqns = [];
28 open(FILE,$file);
29 while (<FILE>) {
30 my $line = $_;
31 if ( m/(\d+\.\d+\.\d+\s*:\s*\(\d+\/\d+\/\d+\))\s+(.*)$/ or m/(\d+\.\d+\.\d+\s*:)\s+$/) {
32 my $version=$1;
33 $version =~ s/\s+:\s+/: /g;
34 if ($start == 1) {
35 # print release notes as bullet points
36 foreach (split /\;/, $out) {
37 print "-$_\n";
38 }
39 if ($do_all==1) {
40 $out = "";
41 print "\n**$version**\n\n";
42 } else {
43 close(FILE);
44 exit()
45 };
46 } else {
47 if ($do_all==1) {
48 print "\n**$version**\n\n";
49 }
50 $start = 1;
51 $out = "";
52 }
53 } elsif ($start == 1) {
54 # last entry, close on matching ---- line
55 if (m/----/) {
56 foreach (split /\;/, $out) {
57 print "-$_\n";
58 }
59 close(FILE);
60 exit()
61 }
62 $line =~ m/\!\s+(.*)$/; # match '! some text' and get rid of ! and spaces
63 $out = "${out} $1"; # append
64 }
65 }