From 54af7955b30636d31fa82693c25df11085f43a6d Mon Sep 17 00:00:00 2001 From: Dylan William Hardison Date: Fri, 28 Apr 2017 13:49:48 -0400 Subject: Bug 1360619 - Move Firefox OS to graveyard Repurpose an old script as a bug resolving implement. --- scripts/close_bugs_wontfix.pl | 81 ------------------------------------- scripts/resolve_bugs.pl | 92 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 92 insertions(+), 81 deletions(-) delete mode 100755 scripts/close_bugs_wontfix.pl create mode 100755 scripts/resolve_bugs.pl (limited to 'scripts') diff --git a/scripts/close_bugs_wontfix.pl b/scripts/close_bugs_wontfix.pl deleted file mode 100755 index 1c80a965d..000000000 --- a/scripts/close_bugs_wontfix.pl +++ /dev/null @@ -1,81 +0,0 @@ -#!/usr/bin/perl -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. -# -# This Source Code Form is "Incompatible With Secondary Licenses", as -# defined by the Mozilla Public License, v. 2.0. - -use 5.10.1; -use strict; -use warnings; -use lib qw(. lib local/lib/perl5); - - -use Bugzilla; -use Bugzilla::Bug; -use Bugzilla::Constants; -use Bugzilla::Group; -use Bugzilla::Search; - -use constant QUERY => { - short_desc => '[B2G]', - resolution => '---', - short_desc_type => 'allwordssubstr', - product => 'Mozilla Localizations' -}; - -use constant COMMENT => "We've stopped shipping Firefox OS for phones. Thus resolving this as WONTFIX."; - -Bugzilla->usage_mode(USAGE_MODE_CMDLINE); - -my $dbh = Bugzilla->dbh; - -# Make all changes as the automation user -my $auto_user = Bugzilla::User->check({ name => 'automation@bmo.tld' }); -$auto_user->{groups} = [ Bugzilla::Group->get_all ]; -$auto_user->{bless_groups} = [ Bugzilla::Group->get_all ]; -Bugzilla->set_user($auto_user); - -my $search = new Bugzilla::Search(fields => ['bug_id'], params => QUERY); -my ($data) = $search->data; - -my $bug_count = @$data; -if ($bug_count == 0) { - warn "There are no bugs to close.\n"; - exit 1; -} - -print STDERR < to stop or to continue... -EOF -getc(); - -my $timestamp = $dbh->selectrow_array('SELECT LOCALTIMESTAMP(0)'); - -$dbh->bz_start_transaction; -foreach my $row (@$data) { - my $bug_id = shift @$row; - warn "Updating bug $bug_id\n"; - my $bug = Bugzilla::Bug->new($bug_id); - $bug->set_bug_status('RESOLVED', { resolution => 'WONTFIX' }); - $bug->add_comment(COMMENT); - $bug->update($timestamp); - $dbh->do("UPDATE bugs SET lastdiffed = ? WHERE bug_id = ?", - undef, $timestamp, $bug_id); -} -$dbh->bz_commit_transaction; - -Bugzilla->memcached->clear_all(); - -__END__ - -=head1 NAME - -close_bugs_wontfix.pl - close bugs matching query as RESOLVED/WONTFIX. - -=head1 SYNOPSIS - - close_bugs_wontfix.pl diff --git a/scripts/resolve_bugs.pl b/scripts/resolve_bugs.pl new file mode 100755 index 000000000..5a9199d39 --- /dev/null +++ b/scripts/resolve_bugs.pl @@ -0,0 +1,92 @@ +#!/usr/bin/perl +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +# This Source Code Form is "Incompatible With Secondary Licenses", as +# defined by the Mozilla Public License, v. 2.0. + +use 5.10.1; +use strict; +use warnings; +use lib qw(. lib local/lib/perl5); + + +use Bugzilla; +use Bugzilla::Bug; +use Bugzilla::Constants; +use Bugzilla::Group; +use Bugzilla::Search; +use Getopt::Long; + +my ($product, $comment); +my $resolution = 'WONTFIX'; + +Bugzilla->usage_mode(USAGE_MODE_CMDLINE); + +GetOptions( + 'product|p=s' => \$product, + 'resolution|r=s' => \$resolution, + 'comment|m=s' => \$comment, +); + +die "--product (-p) is required!\n" unless $product; +die "--comment (-m) is required!\n" unless $comment; + +my $dbh = Bugzilla->dbh; + +# Make all changes as the automation user +my $auto_user = Bugzilla::User->check({ name => 'automation@bmo.tld' }); +$auto_user->{groups} = [ Bugzilla::Group->get_all ]; +$auto_user->{bless_groups} = [ Bugzilla::Group->get_all ]; +Bugzilla->set_user($auto_user); + +my $search = Bugzilla::Search->new( + fields => ['bug_id'], + params => { resolution => '---', product => $product }, +); +my ($data) = $search->data; + +my $bug_count = @$data; +if ($bug_count == 0) { + warn "There are no bugs to close.\n"; + exit 1; +} + +print STDERR < to stop or to continue... +EOF +getc(); + +my $timestamp = $dbh->selectrow_array('SELECT LOCALTIMESTAMP(0)'); + +$dbh->bz_start_transaction; +foreach my $row (@$data) { + my $bug_id = shift @$row; + warn "Updating bug $bug_id\n"; + my $bug = Bugzilla::Bug->new($bug_id); + $bug->set_bug_status('RESOLVED', { resolution => $resolution }); + $bug->add_comment($comment); + $bug->update($timestamp); + $dbh->do("UPDATE bugs SET lastdiffed = ? WHERE bug_id = ?", + undef, $timestamp, $bug_id); + # make sure memory is cleaned up. + Bugzilla::Hook::process('request_cleanup'); + Bugzilla::Bug->CLEANUP; + Bugzilla->clear_request_cache(except => [qw(user dbh dbh_main dbh_shadow memcached)]); +} +$dbh->bz_commit_transaction; + +Bugzilla->memcached->clear_all(); + +__END__ + +=head1 NAME + +close_bugs_wontfix.pl - close bugs matching query as RESOLVED/WONTFIX. + +=head1 SYNOPSIS + + close_bugs_wontfix.pl -- cgit v1.2.3-24-g4f1b