]> git.donarmstrong.com Git - bugscan.git/blob - bugdiff
add missing } to FilterBugsStable
[bugscan.git] / bugdiff
1 #!/usr/bin/perl
2 # vim: ts=8 sw=8 nowrap
3
4 # Compare two buglist status-files
5
6 use Getopt::Std;
7 use File::Basename;
8 use lib dirname(__FILE__);
9 use bugcfg;
10 use scanlib;
11 use strict;
12 use warnings;
13
14 my $Version             = "BugDiff 1.0\nCopyright (C) Wichert Akkerman <wakkerma\@debian.org>\n";
15 my $html                        = 0;
16
17 my (%removed, %new);
18
19 sub ShowVersion() {
20         print "$Version\n";
21         exit 0;
22 }
23
24 sub ShowUsage() {
25         print <<EOF;
26 Usage:
27   $0 [-V] [-h] [-H] <status1> <status2>
28 Options:
29   -V    show version
30   -h    show some (hopefully) helpfull information
31   -H    produce HTML output
32   -n    list newly opened bugs
33   -c    list closed bugs
34   -s    show statistics
35 EOF
36         exit 0;
37 }
38
39 sub closedbugs() {
40         if ($html) {
41                 if (%removed) {
42                         print "<h2>Closed/downgraded release-critical bugs</h2>\n";
43                         print "<ul>\n";
44                         for my $p (sort keys %removed) {
45                                 print "  <li><em>" . &scanlib::wwwname($p) . ":</em>\n";
46                                 for $b (sort @{$removed{$p}}) {
47                                         print &scanlib::wwwnumber($b) . " ";
48                                 }
49                                 print "\n";
50                         }
51                         print "</ul>\n";
52                 }
53         } else {
54                 print "Closed/downgraded release-critical bugs:\n" if (scalar keys %removed>0);
55                 for my $p (sort keys %removed) {
56                         print "   $p: ";
57                         print join(", ", sort @{$removed{$p}});
58                         print "\n";
59                 }
60         }
61 }
62
63
64 sub openedbugs() {
65         if ($html) {
66                 if (%new) {
67                         print "<h2>Opened/upgraded release-critical bugs</h2>\n";
68                         print "<ul>\n";
69                         for my $p (sort keys %new) {
70                                 print "  <li><em>" . &scanlib::wwwname($p) . ":</em>\n";
71                                 for $b (sort @{$new{$p}}) {
72                                         print &scanlib::wwwnumber($b) . " ";
73                                 }
74                                 print "\n";
75                         }
76                         print "</ul>\n";
77                 }
78         } else {
79                 print "Opened/upgraded release-critical bugs:\n" if (%new);
80                 for my $p (sort keys %new) {
81                         print "   $p: ";
82                         print join(", ", sort @{$new{$p}});
83                         print "\n";
84                 }
85         }
86 }
87
88 sub statistics($$) {
89         my ($opened, $closed) = @_;
90
91         if ($html) {
92                 print "<STRONG>" . ($closed ? $closed : "NO") . "</STRONG> release-critical bugs were closed and ";
93                 print "<STRONG>" . ($opened ? $opened : "NONE") . "</STRONG> were opened.<P>\n";
94         } else {
95                 print "" . ($closed ? $closed : "NO") . " release-critical bugs were closed ";
96                 print "and " . ($opened ? $opened : "NONE") . " were opened.\n\n";
97         }
98 }
99
100 our ($opt_V, $opt_h, $opt_H, $opt_n, $opt_c, $opt_s);
101 getopts('VhHncs');
102 ShowUsage if ($opt_h or ($#ARGV != 1));
103 ShowVersion if ($opt_V);
104 $html=1 if ($opt_H);
105
106 scanlib::readstatus($ARGV[0]);
107 my %oldbugs=%scanlib::packagelist;
108 %scanlib::packagelist=();
109
110 scanlib::readstatus($ARGV[1]);
111
112 my $closed=0;
113 for my $p (keys %oldbugs) {
114         for $b (@{$oldbugs{$p}}) {
115                 if (!defined($scanlib::packagelist{$p}) || scalar grep { $_ == $b } @{$scanlib::packagelist{$p}} == 0) { 
116                         push @{$removed{$p}}, $b;
117                         $closed++;
118                 }
119         }
120 }
121
122 my $opened=0;
123 for my $p (keys %scanlib::packagelist) {
124         for $b (@{$scanlib::packagelist{$p}}) {
125                 if (!defined($oldbugs{$p}) || scalar grep { $_ == $b } @{$oldbugs{$p}} == 0) { 
126                         push @{$new{$p}}, $b;
127                         $opened++;
128                 }
129         }
130 }
131
132 statistics($opened, $closed) if ($opt_s);
133 closedbugs if ($opt_c);
134 openedbugs if ($opt_n);
135
136 exit 0;
137