Skip to content

Commit 1780f99

Browse files
committed
Bug 1981211 - when uploading patches that have .toml file changes and the reviewer is #intermittent-reviewers, do not add group reviewers as blocking
1 parent 5d489aa commit 1780f99

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

extensions/PhabBugz/lib/Feed.pm

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ use Bugzilla::Extension::PhabBugz::Util qw(
4242
request
4343
set_attachment_approval_flags
4444
set_phab_user
45+
set_intermittent_reviewers
4546
set_reviewer_rotation
4647
);
4748

@@ -775,6 +776,10 @@ sub process_revision_change {
775776
$bug->update($timestamp);
776777
$revision->update();
777778

779+
# 1981211 - If reviewer is #intermittent-reviewers and #taskgraph-reviewers do not allow other
780+
# group reviewers as blocking. Instead move any other blocking reviewers to the subscriber list.
781+
set_intermittent_reviewers($revision);
782+
778783
### Phabricator Reviewer Rotation
779784
# This should happen after all of the above changes and Herald has had a chance to run.
780785
set_reviewer_rotation($revision);

extensions/PhabBugz/lib/Util.pm

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ our @EXPORT = qw(
4141
set_attachment_approval_flags
4242
set_phab_user
4343
set_reviewer_rotation
44+
set_intermittent_reviewers
4445
);
4546

4647
use constant LEGACY_APPROVAL_MAPPING => {
@@ -627,4 +628,49 @@ sub get_review_users {
627628
return @review_users;
628629
}
629630

631+
# 1981211 - If reviewer is #intermittent-reviewers and #taskgraph-reviewers do not allow other
632+
# group reviewers as blocking. Instead move any other blocking reviewers to the subscriber list.
633+
sub set_intermittent_reviewers {
634+
my ($revision) = @_;
635+
636+
INFO('D' . $revision->id . ': Setting intermittent reviewers');
637+
638+
# Load a fresh version of the revision with Heralds changes.
639+
$revision = Bugzilla::Extension::PhabBugz::Revision->new_from_query(
640+
{phids => [$revision->phid]});
641+
642+
# Look up all blocking projects currently on the revision
643+
INFO('Retrieving blocking projects');
644+
645+
my @blocking_projects;
646+
foreach my $reviewer (@{$revision->reviews || []}) {
647+
next if !$reviewer->{is_project} || !$reviewer->{is_blocking};
648+
push @blocking_projects, $reviewer->{user};
649+
}
650+
651+
INFO('Blocking projects found: ' . (@blocking_projects ? (join ', ', map { $_->name } @blocking_projects) : 'None'));
652+
653+
# Return unless the revision has both intermittent-reviewers and taskgraph-reviewers
654+
my $has_intermittent = any { $_->name eq 'intermittent-reviewers' } @blocking_projects;
655+
my $has_taskgraph = any { $_->name eq 'taskgraph-reviewers' } @blocking_projects;
656+
if (!$has_intermittent || !$has_taskgraph) {
657+
INFO('Intermittent or taskgraph reviewers project not found. Returning.');
658+
return;
659+
}
660+
661+
# Now we need to remove the intermittent-reviewers project and the taskgraph-reviewers project,
662+
# and move any remaining to the subscribers list
663+
foreach my $project (@blocking_projects) {
664+
next if $project->name eq 'intermittent-reviewers' || $project->name eq 'taskgraph-reviewers';
665+
666+
INFO('Removing blocking project ' . $project->name);
667+
$revision->remove_reviewer($project->phid);
668+
669+
INFO('Adding blocking project ' . $project->name . ' to subscribers');
670+
$revision->add_subscriber($project->phid);
671+
}
672+
673+
$revision->update;
674+
}
675+
630676
1;

0 commit comments

Comments
 (0)