From: dklawren Date: Mon, 9 Dec 2019 14:59:17 +0000 (-0500) Subject: Bug 1599620 - Don't auto-assign if there are no reviewers specified. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e719b73dcd4028a3c538a15441607895934f8c9a;p=thirdparty%2Fbugzilla.git Bug 1599620 - Don't auto-assign if there are no reviewers specified. --- diff --git a/extensions/PhabBugz/lib/Util.pm b/extensions/PhabBugz/lib/Util.pm index 11f9a314f..21e109106 100644 --- a/extensions/PhabBugz/lib/Util.pm +++ b/extensions/PhabBugz/lib/Util.pm @@ -54,44 +54,46 @@ sub create_revision_attachment { # BMO does not contain actual diff content. my @review_attachments = grep { is_attachment_phab_revision($_) } @{$bug->attachments}; - my $review_attachment + my $attachment = first { trim($_->data) eq $revision_uri } @review_attachments; - return $review_attachment if defined $review_attachment; - # No attachment is present, so we can now create new one + if (!defined $attachment) { + # No attachment is present, so we can now create new one - if (!$timestamp) { - ($timestamp) = Bugzilla->dbh->selectrow_array("SELECT NOW()"); - } - - # If submitter, then switch to that user when creating attachment - local $submitter->{groups} = [Bugzilla::Group->get_all]; # We need to always be able to add attachment - my $restore_prev_user = Bugzilla->set_user($submitter, scope_guard => 1); - - my $attachment = Bugzilla::Attachment->create({ - bug => $bug, - creation_ts => $timestamp, - data => $revision_uri, - description => $revision->title, - filename => 'phabricator-D' . $revision->id . '-url.txt', - ispatch => 0, - isprivate => 0, - mimetype => PHAB_CONTENT_TYPE, - }); - - # Insert a comment about the new attachment into the database. - $bug->add_comment( - $revision->summary, - { - type => CMT_ATTACHMENT_CREATED, - extra_data => $attachment->id, - is_markdown => (Bugzilla->params->{use_markdown} ? 1 : 0) + if (!$timestamp) { + ($timestamp) = Bugzilla->dbh->selectrow_array("SELECT NOW()"); } - ); - delete $bug->{attachments}; - # Assign the bug to the submitter if it isn't already owned. - unless (is_bug_assigned($bug)) { + # If submitter, then switch to that user when creating attachment + local $submitter->{groups} = [Bugzilla::Group->get_all]; # We need to always be able to add attachment + my $restore_prev_user = Bugzilla->set_user($submitter, scope_guard => 1); + + $attachment = Bugzilla::Attachment->create({ + bug => $bug, + creation_ts => $timestamp, + data => $revision_uri, + description => $revision->title, + filename => 'phabricator-D' . $revision->id . '-url.txt', + ispatch => 0, + isprivate => 0, + mimetype => PHAB_CONTENT_TYPE, + }); + + # Insert a comment about the new attachment into the database. + $bug->add_comment( + $revision->summary, + { + type => CMT_ATTACHMENT_CREATED, + extra_data => $attachment->id, + is_markdown => (Bugzilla->params->{use_markdown} ? 1 : 0) + } + ); + delete $bug->{attachments}; + } + + # Assign the bug to the submitter if it isn't already owned and + # the revision has reviewers assigned to it. + if (!is_bug_assigned($bug) && @{$revision->reviews}) { $bug->set_assigned_to($submitter); $bug->set_bug_status('ASSIGNED') if $bug->status->name eq 'NEW'; }