3 # ----------------------------------------------------------------------------
7 # Little script that outputs a list of N random open bugs from bugzilla
8 # for a certain bugzilla product
10 # ----------------------------------------------------------------------------
12 # Copyright (C) 2011-2012 Tim-Philipp Muller <tim centricular net>
14 # This script is free software; you can redistribute it and/or
15 # modify it under the terms of the GNU Library General Public
16 # License as published by the Free Software Foundation; either
17 # version 2 of the License, or (at your option) any later version.
19 # This library is distributed in the hope that it will be useful,
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 # Library General Public License for more details.
24 # You should have received a copy of the GNU Library General Public
25 # License along with this library; if not, write to the
26 # Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
27 # Boston, MA 02110-1301, USA.
29 # ----------------------------------------------------------------------------
31 # You can use it to send yourself an e-mail with a few bugs to check up on
32 # every day, just put it into your crontab on a computer of your choice
33 # (with proper e-mail forwarding configured in some way):
39 # MAILTO=you@nowhere.org
40 # # send ten random buglinks every day at 16.30
41 # 30 16 * * * /usr/bin/perl /path/to/five-bugs-a-day.pl
44 # Yes, it's PERL, sorry.
46 # Yes, I know the default is 10 bugs.
48 # ----------------------------------------------------------------------------
50 # ----------------------------------------------------------------------------
52 # ----------------------------------------------------------------------------
60 my $j = int rand( $i+1 );
61 @$array[$i,$j] = @$array[$j,$i];
67 # ----------------------------------------------------------------------------
69 # ----------------------------------------------------------------------------
73 my $PRODUCT = "GStreamer";
75 # ----- command line options -----
78 $NUM_BUGS = shift @ARGV;
82 $PRODUCT = shift @ARGV;
86 my $QUERY_URL = "https://bugzilla.gnome.org/buglist.cgi?product=$PRODUCT&" .
87 'bug_status=UNCONFIRMED&bug_status=NEW&bug_status=ASSIGNED&' .
88 'bug_status=REOPENED&' .
89 'query_format=advanced&ctype=csv';
96 # for testing/debugging:
97 # unless (@lines = `cat bugs.csv`) {
98 unless (@lines = `wget --no-check-certificate --quiet -O - '$QUERY_URL'`) {
99 die 'Could not download bug list';
102 # ----- parse column headers -----
106 # get first line which contains the field names
107 $headers = shift @lines;
109 # get rid of newline at end
112 my @fields = split (/,/, $headers);
113 my $num_fields = scalar(@fields);
115 for (my $c = 0; $c < $num_fields; $c++) {
116 #print "$c $fields[$c] \n";
117 if ($fields[$c] =~ m/bug_id/) {
119 } elsif ($fields[$c] =~ m/short_desc/) {
124 die "Could not find bug_id column in CVS file" if not defined ($COL_ID);
125 die "Could not find short_desc column in CVS file" if not defined ($COL_DESC);
127 #print "bugid is column $COL_ID\n";
128 #print "desc is column $COL_DESC\n";
134 # We specify num_fields as limit here, because the short_desc field
135 # might contain commas as well, and we don't want it to get cut off.
136 # This is a hack for the fact that we don't handle quoted fields
137 # (12345,"UNCONFIRMED","foo, bar: errors out") properly. As long as the
138 # short_desc field is the last one, that should be ok. (FIXME)
139 my @vals = split (/,/, $_, $num_fields);
140 my $id = $vals[$COL_ID];
141 my $desc = $vals[$COL_DESC];
143 $desc =~ s/^"(.*)"$/$1/;
148 my @all_bugs = keys %BUGS;
149 my @bugs = shuffle (\@all_bugs);
151 # only want first NUM_BUGS bugs
152 @bugs = splice (@bugs, 0, $NUM_BUGS);
155 print "$NUM_BUGS random bugs:\n";
158 for my $bug_id ( @bugs ) {
159 print "$BUGS{$bug_id}\n";
160 print "https://bugzilla.gnome.org/show_bug.cgi?id=$bug_id\n";
165 print "More bugs at:\n";
166 print " - http://gstreamer.freedesktop.org/bugs/\n";
167 print " - https://bugzilla.gnome.org/browse.cgi?product=GStreamer\n";