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/Push/lib/Connector/Phabricator.pm | 153 +++++++++++++-------------- 1 file changed, 72 insertions(+), 81 deletions(-) (limited to 'extensions/Push/lib/Connector/Phabricator.pm') diff --git a/extensions/Push/lib/Connector/Phabricator.pm b/extensions/Push/lib/Connector/Phabricator.pm index 33e2bb6ad..61a39e32b 100644 --- a/extensions/Push/lib/Connector/Phabricator.pm +++ b/extensions/Push/lib/Connector/Phabricator.pm @@ -29,105 +29,96 @@ use Bugzilla::Extension::Push::Constants; use Bugzilla::Extension::Push::Util qw(is_public); sub options { - return ( - { - name => 'phabricator_url', - label => 'Phabricator URL', - type => 'string', - default => '', - required => 1, - } - ); + return ({ + name => 'phabricator_url', + label => 'Phabricator URL', + type => 'string', + default => '', + required => 1, + }); } sub should_send { - my ( $self, $message ) = @_; + my ($self, $message) = @_; - return 0 unless Bugzilla->params->{phabricator_enabled}; + return 0 unless Bugzilla->params->{phabricator_enabled}; - # We are only interested currently in bug group, assignee, qa-contact, or cc changes. - return 0 - unless $message->routing_key =~ - /^(?:attachment|bug)\.modify:.*\b(bug_group|assigned_to|qa_contact|cc)\b/; +# We are only interested currently in bug group, assignee, qa-contact, or cc changes. + return 0 + unless $message->routing_key + =~ /^(?:attachment|bug)\.modify:.*\b(bug_group|assigned_to|qa_contact|cc)\b/; - my $bug = $self->_get_bug_by_data( $message->payload_decoded ) || return 0; + my $bug = $self->_get_bug_by_data($message->payload_decoded) || return 0; - return $bug->has_attachment_with_mimetype(PHAB_CONTENT_TYPE); + return $bug->has_attachment_with_mimetype(PHAB_CONTENT_TYPE); } sub send { - my ( $self, $message ) = @_; - - my $logger = Bugzilla->push_ext->logger; - - my $data = $message->payload_decoded; - - my $bug = $self->_get_bug_by_data($data) || return PUSH_RESULT_OK; - - my $is_public = is_public($bug); - - my $revisions = get_attachment_revisions($bug); - - my $group_change = - ($message->routing_key =~ /^(?:attachment|bug)\.modify:.*\bbug_group\b/) - ? 1 - : 0; - - foreach my $revision (@$revisions) { - if ( $is_public && $group_change ) { - Bugzilla->audit(sprintf( - 'Making revision %s public for bug %s', - $revision->id, - $bug->id - )); - $revision->make_public(); - } - elsif ( !$is_public && $group_change ) { - Bugzilla->audit(sprintf( - 'Giving revision %s a custom policy for bug %s', - $revision->id, - $bug->id - )); - my $set_project_names = [ map { "bmo-" . $_->name } @{ $bug->groups_in } ]; - $revision->make_private($set_project_names); - } - - # Subscriber list of the private revision should always match - # the bug roles such as assignee, qa contact, and cc members. - if (!$is_public) { - Bugzilla->audit(sprintf( - 'Updating subscribers for %s for bug %s', - $revision->id, - $bug->id - )); - my $subscribers = get_bug_role_phids($bug); - $revision->set_subscribers($subscribers) if $subscribers; - } - - $revision->update(); + my ($self, $message) = @_; + + my $logger = Bugzilla->push_ext->logger; + + my $data = $message->payload_decoded; + + my $bug = $self->_get_bug_by_data($data) || return PUSH_RESULT_OK; + + my $is_public = is_public($bug); + + my $revisions = get_attachment_revisions($bug); + + my $group_change + = ($message->routing_key =~ /^(?:attachment|bug)\.modify:.*\bbug_group\b/) + ? 1 + : 0; + + foreach my $revision (@$revisions) { + if ($is_public && $group_change) { + Bugzilla->audit( + sprintf('Making revision %s public for bug %s', $revision->id, $bug->id)); + $revision->make_public(); } + elsif (!$is_public && $group_change) { + Bugzilla->audit(sprintf( + 'Giving revision %s a custom policy for bug %s', + $revision->id, $bug->id + )); + my $set_project_names = [map { "bmo-" . $_->name } @{$bug->groups_in}]; + $revision->make_private($set_project_names); + } + + # Subscriber list of the private revision should always match + # the bug roles such as assignee, qa contact, and cc members. + if (!$is_public) { + Bugzilla->audit( + sprintf('Updating subscribers for %s for bug %s', $revision->id, $bug->id)); + my $subscribers = get_bug_role_phids($bug); + $revision->set_subscribers($subscribers) if $subscribers; + } + + $revision->update(); + } - return PUSH_RESULT_OK; + return PUSH_RESULT_OK; } sub _get_bug_by_data { - my ( $self, $data ) = @_; - my $bug_data = $self->_get_bug_data($data) || return 0; - my $bug = Bugzilla::Bug->new( { id => $bug_data->{id} } ); + my ($self, $data) = @_; + my $bug_data = $self->_get_bug_data($data) || return 0; + my $bug = Bugzilla::Bug->new({id => $bug_data->{id}}); } sub _get_bug_data { - my ( $self, $data ) = @_; - my $target = $data->{event}->{target}; - if ( $target eq 'bug' ) { - return $data->{bug}; - } - elsif ( exists $data->{$target}->{bug} ) { - return $data->{$target}->{bug}; - } - else { - return; - } + my ($self, $data) = @_; + my $target = $data->{event}->{target}; + if ($target eq 'bug') { + return $data->{bug}; + } + elsif (exists $data->{$target}->{bug}) { + return $data->{$target}->{bug}; + } + else { + return; + } } 1; -- cgit v1.2.3-24-g4f1b