diff options
Diffstat (limited to 'scripts/resolve_bugs.pl')
-rwxr-xr-x | scripts/resolve_bugs.pl | 67 |
1 files changed, 33 insertions, 34 deletions
diff --git a/scripts/resolve_bugs.pl b/scripts/resolve_bugs.pl index 70ed30c23..324dd06ac 100755 --- a/scripts/resolve_bugs.pl +++ b/scripts/resolve_bugs.pl @@ -25,10 +25,10 @@ my $resolution = 'WONTFIX'; Bugzilla->usage_mode(USAGE_MODE_CMDLINE); GetOptions( - 'product|p=s' => \$product, - 'resolution|r=s' => \$resolution, - 'component|c=s' => \$component, - 'comment|m=s' => \$comment, + 'product|p=s' => \$product, + 'resolution|r=s' => \$resolution, + 'component|c=s' => \$component, + 'comment|m=s' => \$comment, ); die "--product (-p) is required!\n" unless $product; @@ -37,55 +37,54 @@ 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 ]; +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 $query = { resolution => '---', product => $product }; +my $query = {resolution => '---', product => $product}; $query->{component} = $component if defined $component; -my $search = Bugzilla::Search->new( - fields => ['bug_id'], - params => $query, -); +my $search = Bugzilla::Search->new(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; + warn "There are no bugs to close.\n"; + exit 1; } # if running from commmand line if (-t STDIN) { - print STDERR <<EOF; + print STDERR <<EOF; About to resolve $bug_count bugs as $resolution Press <Ctrl-C> to stop or <Enter> to continue... EOF - getc(); + getc(); } foreach my $row (@$data) { - my $bug_id = shift @$row; - warn "Updating bug $bug_id\n"; - - my $timestamp = $dbh->selectrow_array('SELECT LOCALTIMESTAMP(0)'); - - $dbh->bz_start_transaction; - 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; + my $bug_id = shift @$row; + warn "Updating bug $bug_id\n"; + + my $timestamp = $dbh->selectrow_array('SELECT LOCALTIMESTAMP(0)'); + + $dbh->bz_start_transaction; + 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(); |