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., 59 Temple Place - Suite 330,
27 # Boston, MA 02111-1307, 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 # ----------------------------------------------------------------------------
51 # - there may be an issue with apostrophes or quotes in bug summaries,
52 # descriptions sometimes get cut off
54 # ----------------------------------------------------------------------------
56 # ----------------------------------------------------------------------------
58 # ----------------------------------------------------------------------------
66 my $j = int rand( $i+1 );
67 print "j = $j, i = $i \n";
68 @$array[$i,$j] = @$array[$j,$i];
74 # ----------------------------------------------------------------------------
76 # ----------------------------------------------------------------------------
80 my $PRODUCT = "GStreamer";
82 # ----- command line options -----
85 $NUM_BUGS = shift @ARGV;
89 $PRODUCT = shift @ARGV;
93 my $QUERY_URL = "https://bugzilla.gnome.org/buglist.cgi?product=$PRODUCT&" .
94 'bug_status=UNCONFIRMED&bug_status=NEW&bug_status=ASSIGNED&' .
95 'bug_status=REOPENED&' .
96 'query_format=advanced&ctype=csv';
103 # for testing/debugging:
104 # unless (@lines = `cat bugs.csv`) {
105 unless (@lines = `wget --no-check-certificate --quiet -O - '$QUERY_URL'`) {
106 die 'Could not download bug list';
109 # ----- parse column headers -----
113 # get first line which contains the field names
114 $headers = shift @lines;
116 # get rid of newline at end
119 my @fields = split (/,/, $headers);
120 my $num_fields = scalar(@fields);
122 for (my $c = 0; $c < $num_fields; $c++) {
123 #print "$c $fields[$c] \n";
124 if ($fields[$c] =~ m/bug_id/) {
126 } elsif ($fields[$c] =~ m/short_desc/) {
131 die "Could not find bug_id column in CVS file" if not defined ($COL_ID);
132 die "Could not find short_desc column in CVS file" if not defined ($COL_DESC);
134 #print "bugid is column $COL_ID\n";
135 #print "desc is column $COL_DESC\n";
141 # We specify num_fields as limit here, because the short_desc field
142 # might contain commas as well, and we don't want it to get cut off.
143 # This is a hack for the fact that we don't handle quoted fields
144 # (12345,"UNCONFIRMED","foo, bar: errors out") properly. As long as the
145 # short_desc field is the last one, that should be ok. (FIXME)
146 my @vals = split (/,/, $_, $num_fields);
147 my $id = $vals[$COL_ID];
148 my $desc = $vals[$COL_DESC];
150 $desc =~ s/^"(.*)"$/$1/;
155 my @all_bugs = keys %BUGS;
156 my @bugs = shuffle (\@all_bugs);
158 # only want first NUM_BUGS bugs
162 print "$NUM_BUGS random bugs:\n";
165 for my $bug_id ( @bugs ) {
166 print "$BUGS{$bug_id}\n";
167 print "https://bugzilla.gnome.org/show_bug.cgi?id=$bug_id\n";
172 print "More bugs at:\n";
173 print " - http://gstreamer.freedesktop.org/bugs/\n";
174 print " - https://bugzilla.gnome.org/browse.cgi?product=GStreamer\n";