@@ -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
4647use 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+
6306761;
0 commit comments