2 # -*- Mode: perl; indent-tabs-mode: nil -*-
7 # Copyright (C) 2000 Eazel, Inc.
9 # This library is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU General Public License as
11 # published by the Free Software Foundation; either version 2 of the
12 # License, or (at your option) any later version.
14 # This library is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 # General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with this library; if not, write to the Free Software
21 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 # Author: Darin Adler <darin@bentspoon.com>,
26 # check-FIXME.pl: Search for FIXMEs in the sources and correlate them
27 # with bugs in the bug database.
32 # default to all the files starting from the current directory
36 @ARGV = `find . \\( \\( -name po -prune -false \\) -or \\( -name CVS -prune -false \\) -or \\( -name macros -prune -false \\) -or \\( -name '*' -and -type f \\) \\) -and ! \\( -name '*~' -or -name '#*' -or -name 'ChangeLog*' -or -name Entries \\) -print`;
42 "./check-FIXME.pl" => 1,
50 #locate all of the open FIXMEs in the bug database
54 my $repository_file = $pwd."/CVS/Repository";
55 open FILE
, " cat $repository_file | ";
62 print "Searching the bugzilla database's product $product for open FIXME bugs\n";
64 if (!grep /$product/, ( "nautilus", "gnome-vfs", "medusa", "oaf")) {
65 print "Can't find your product in the bugzilla.gnome.org database\n";
68 my $bugzilla_query_bug_url = "http://bugzilla.gnome.org/buglist.cgi?";
70 $product =~ s/\-/\+/g;
71 my @cgi_options = ("bug_status=NEW",
72 "bug_status=ASSIGNED",
73 "bug_status=REOPENED",
75 "long_desc_type=substring",
78 my $open_fixmes_url = $bugzilla_query_bug_url.join "&", @cgi_options;
80 `wget -q -O - "$open_fixmes_url"` =~ /<INPUT TYPE\=HIDDEN NAME\=buglist VALUE\=([0-9:]+)>/;
81 my $buglist_text = $1;
84 foreach my $bug (split /:/, $buglist_text) {
85 $bugs_in_bugzilla{$bug} = "UNFOUND";
88 print "Locating all of the FIXME's listed in source\n";
89 # locate all of the target lines
90 my $no_bug_lines = "";
92 foreach my $file (@ARGV)
95 next if $skip_files{$file};
97 open(FILE
, $file) || die "can't open $file";
101 if (/FIXME\s*:?\s*bugzilla.gnome.org\s+(\d+)/)
103 $bug_lines{$1} .= "$file:$.:$_";
107 $no_bug_lines .= "$file:$.:$_";
113 # list database bugs we can't find in nautilus
114 printf "%d FIXMES in the database still in $product\n", keys %bug_lines;
116 foreach my $bug_number (keys %bug_lines) {
117 $bugs_in_bugzilla{$bug_number} = "FOUND";
121 foreach my $bug_number (keys %bugs_in_bugzilla) {
122 if ($bugs_in_bugzilla{$bug_number} eq "UNFOUND") {
123 # Also check that the
124 my $bug_url = "http://bugzilla.gnome.org/show_bug.cgi?id=".$bug_number;
125 my $bug_page = `wget -q -O - $bug_url`;
126 if (!($bug_page =~ /This is not a FIXME bug/i)) {
127 $bug_page =~ /<A HREF=\"bug_status.html\#assigned_to\">Assigned To:<\/A
><\
/B><\/TD
>\s
+<TD
>([^<]+)<\
/TD>/s;
128 print "Bug $bug_number isn't in the source anymore. Contact owner $1.\n";
134 # list the ones without bug numbers
135 if ($no_bug_lines ne "")
137 my @no_bug_list = sort split /\n/, $no_bug_lines;
138 print "\n", scalar(@no_bug_list), " FIXMEs don't have bug numbers:\n\n";
139 foreach my $line (@no_bug_list)
145 # list the ones with bugs that are not open
146 print "\n", scalar(keys %bug_lines), " FIXMEs with bug numbers.\n";
147 sub numerically
{ $a <=> $b; }
148 foreach my $bug (sort numerically
keys %bug_lines)
150 # Check and see if the bug is open.
151 my $page = `wget -q -O - http://bugzilla.gnome.org/show_bug.cgi?id=$bug`;
153 my $status = "unknown";
154 $status = $1 if $page =~ m
|Status
:.*</TD>\s*<TD>([A-Z]+)</TD
>|;
155 next if $status eq "NEW" || $status eq "ASSIGNED" || $status eq "REOPENED";
157 # This a bug that is not open, so report it.
158 my @bug_line_list = sort split /\n/, $bug_lines{$bug};
159 print "\nBug $bug is $status:\n\n";
160 foreach my $line (@bug_line_list)