From 8ec8da0491ad89604700b3e29a227966f6d84ba1 Mon Sep 17 00:00:00 2001 From: Perl Tidy Date: Wed, 5 Dec 2018 15:38:52 -0500 Subject: no bug - reformat all the code using the new perltidy rules --- scripts/migrate-cab-review.pl | 71 ++++++++++++++++++++----------------------- 1 file changed, 33 insertions(+), 38 deletions(-) (limited to 'scripts/migrate-cab-review.pl') diff --git a/scripts/migrate-cab-review.pl b/scripts/migrate-cab-review.pl index b4665f255..5cfb0ca2d 100755 --- a/scripts/migrate-cab-review.pl +++ b/scripts/migrate-cab-review.pl @@ -12,8 +12,6 @@ use warnings; use lib qw(. lib local/lib/perl5); - - use Bugzilla; use Bugzilla::Bug; use Bugzilla::Constants; @@ -27,24 +25,20 @@ 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 ]; +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); # cab-review flag values to custom field values mapping -my %map = ( - '?' => '?', - '+' => 'approved', - '-' => 'denied' -); +my %map = ('?' => '?', '+' => 'approved', '-' => 'denied'); # Verify that all of the custom field values in the mapping data are present -my $cab_field = Bugzilla::Field->check({ name => 'cf_cab_review' }); +my $cab_field = Bugzilla::Field->check({name => 'cf_cab_review'}); foreach my $value (values %map) { - unless (grep($_ eq $value, map { $_->name } @{ $cab_field->legal_values })) { - die "Value '$value' does not exist. Please add to 'cf_cab_review.\n"; - } + unless (grep($_ eq $value, map { $_->name } @{$cab_field->legal_values})) { + die "Value '$value' does not exist. Please add to 'cf_cab_review.\n"; + } } # Grab list of bugs with cab-review flag set @@ -61,43 +55,44 @@ my $bugs = $dbh->selectcol_arrayref($sql); my ($current, $total, $updated) = (1, scalar(@$bugs), 0); die "No matching bugs found\n" unless $total; -print "About to update $total bugs with cab-review flags set and migrate to the cf_cab_review custom field.\n"; +print + "About to update $total bugs with cab-review flags set and migrate to the cf_cab_review custom field.\n"; print "Press to start, or ^C to cancel...\n"; <>; foreach my $bug_id (@$bugs) { - indicate_progress({ current => $current++, total => $total, every => 5 }); + indicate_progress({current => $current++, total => $total, every => 5}); - # Load bug object - my $bug = Bugzilla::Bug->new($bug_id); + # Load bug object + my $bug = Bugzilla::Bug->new($bug_id); - # Find the current cab-review status - my $cab_flag; - foreach my $flag (@{ $bug->flags }) { - next if $flag->type->name ne 'cab-review'; - $cab_flag = $flag; - last; - } + # Find the current cab-review status + my $cab_flag; + foreach my $flag (@{$bug->flags}) { + next if $flag->type->name ne 'cab-review'; + $cab_flag = $flag; + last; + } - my $timestamp = $dbh->selectrow_array('SELECT LOCALTIMESTAMP(0)'); + my $timestamp = $dbh->selectrow_array('SELECT LOCALTIMESTAMP(0)'); - $dbh->bz_start_transaction; + $dbh->bz_start_transaction; - # Set the cab-review custom field to the right status based on the mapped values - $bug->set_custom_field($cab_field, $map{$cab_flag->status}); + # Set the cab-review custom field to the right status based on the mapped values + $bug->set_custom_field($cab_field, $map{$cab_flag->status}); - # Clear the old cab-review flag - $bug->set_flags([{ id => $cab_flag->id, status => 'X' }], []); + # Clear the old cab-review flag + $bug->set_flags([{id => $cab_flag->id, status => 'X'}], []); - # Update the bug - $bug->update($timestamp); + # Update the bug + $bug->update($timestamp); - # Do not send email about this change - $dbh->do("UPDATE bugs SET delta_ts = ?, lastdiffed = ? WHERE bug_id = ?", - undef, $timestamp, $timestamp, $bug_id); + # Do not send email about this change + $dbh->do("UPDATE bugs SET delta_ts = ?, lastdiffed = ? WHERE bug_id = ?", + undef, $timestamp, $timestamp, $bug_id); - $dbh->bz_commit_transaction; - $updated++; + $dbh->bz_commit_transaction; + $updated++; } print "Bugs updated: $updated\n"; -- cgit v1.2.3-24-g4f1b