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 --- extensions/BMO/bin/migrate-github-pull-requests.pl | 67 ++++++++++------------ 1 file changed, 30 insertions(+), 37 deletions(-) (limited to 'extensions/BMO/bin/migrate-github-pull-requests.pl') diff --git a/extensions/BMO/bin/migrate-github-pull-requests.pl b/extensions/BMO/bin/migrate-github-pull-requests.pl index c39778a4a..c8afdedfb 100755 --- a/extensions/BMO/bin/migrate-github-pull-requests.pl +++ b/extensions/BMO/bin/migrate-github-pull-requests.pl @@ -22,9 +22,9 @@ use Bugzilla::Install::Util qw(indicate_progress); use Bugzilla::User; use Bugzilla::Util qw(trim); -my $dbh = Bugzilla->dbh; -my $nobody = Bugzilla::User->check({ name => Bugzilla->params->{'nobody_user'} }); -my $field = Bugzilla::Field->check({ name => 'attachments.mimetype' }); +my $dbh = Bugzilla->dbh; +my $nobody = Bugzilla::User->check({name => Bugzilla->params->{'nobody_user'}}); +my $field = Bugzilla::Field->check({name => 'attachments.mimetype'}); # grab list of suitable attachments @@ -42,7 +42,7 @@ SELECT attachments.attach_id, AND LENGTH(thedata) <= 256 EOF print "Searching for suitable attachments..\n"; -my $attachments = $dbh->selectall_arrayref($sql, { Slice => {} }); +my $attachments = $dbh->selectall_arrayref($sql, {Slice => {}}); my ($current, $total, $updated) = (1, scalar(@$attachments), 0); die "No suitable attachments found\n" unless $total; @@ -52,39 +52,32 @@ print "Press to start, or ^C to cancel...\n"; <>; foreach my $attachment (@$attachments) { - indicate_progress({ current => $current++, total => $total, every => 25 }); - - # check payload - my $url = trim($attachment->{thedata}); - next if $url =~ /\s/; - next unless $url =~ m#^https://github\.com/[^/]+/[^/]+/pull/\d+\/?$#i; - - $dbh->bz_start_transaction; - - # set content-type - $dbh->do( - "UPDATE attachments SET mimetype = ? WHERE attach_id = ?", - undef, - 'text/x-github-pull-request', $attachment->{attach_id} - ); - - # insert into bugs_activity - my $timestamp = $dbh->selectrow_array('SELECT LOCALTIMESTAMP(0)'); - $dbh->do( - "INSERT INTO bugs_activity(bug_id, who, bug_when, fieldid, removed, added) - VALUES (?, ?, ?, ?, ?, ?)", - undef, - $attachment->{bug_id}, $nobody->id, $timestamp, $field->id, - $attachment->{mimetype}, 'text/x-github-pull-request' - ); - $dbh->do( - "UPDATE bugs SET delta_ts = ?, lastdiffed = ? WHERE bug_id = ?", - undef, - $timestamp, $timestamp, $attachment->{bug_id} - ); - - $dbh->bz_commit_transaction; - $updated++; + indicate_progress({current => $current++, total => $total, every => 25}); + + # check payload + my $url = trim($attachment->{thedata}); + next if $url =~ /\s/; + next unless $url =~ m#^https://github\.com/[^/]+/[^/]+/pull/\d+\/?$#i; + + $dbh->bz_start_transaction; + + # set content-type + $dbh->do("UPDATE attachments SET mimetype = ? WHERE attach_id = ?", + undef, 'text/x-github-pull-request', $attachment->{attach_id}); + + # insert into bugs_activity + my $timestamp = $dbh->selectrow_array('SELECT LOCALTIMESTAMP(0)'); + $dbh->do( + "INSERT INTO bugs_activity(bug_id, who, bug_when, fieldid, removed, added) + VALUES (?, ?, ?, ?, ?, ?)", undef, $attachment->{bug_id}, + $nobody->id, $timestamp, $field->id, $attachment->{mimetype}, + 'text/x-github-pull-request' + ); + $dbh->do("UPDATE bugs SET delta_ts = ?, lastdiffed = ? WHERE bug_id = ?", + undef, $timestamp, $timestamp, $attachment->{bug_id}); + + $dbh->bz_commit_transaction; + $updated++; } print "Attachments updated: $updated\n"; -- cgit v1.2.3-24-g4f1b