@@ -325,35 +325,27 @@ class Scheduler {
325325 await cancelPreSubmitTargets (pullRequest: pullRequest, reason: reason);
326326
327327 final slug = pullRequest.base ! .repo! .slug ();
328- final isFusion = slug == Config .flutterSlug;
329328
330329 // The MQ only waits for "required status checks" before deciding whether to
331330 // merge the PR into the target branch. This required check added to both
332331 // the PR and to the merge group, and so it must be completed in both cases.
333- final CheckRun ? lock;
334- {
335- final prBranch = pullRequest.head! .ref;
336- if (isFusion && Config .defaultBranch (slug) == prBranch) {
337- lock = await _lockMergeGroupChecks (slug, pullRequest.head! .sha! );
338- } else {
339- lock = null ;
340- log.debug ('Skipping merge queue guard: $slug /$prBranch ' );
341- }
342- }
332+ final lock = await lockMergeGroupChecks (slug, pullRequest.head! .sha! );
343333
344- // Track if we should unlock the merge group lock in case of rever bots.
345- // This is different than simply not having a lock - because flutter/flutter
346- // master requires to see the lock existing and have been passed (versus
347- // non-existence).
334+ // Track if we should unlock the merge group lock in case of non-fusion or
335+ // revert bots.
348336 var unlockMergeGroup = false ;
349337
350338 final ciValidationCheckRun = await _createCiYamlCheckRun (pullRequest, slug);
351339
352340 log.info ('Creating presubmit targets for ${pullRequest .number }' );
353341 Object ? exception;
342+ final isFusion = slug == Config .flutterSlug;
354343 do {
355344 try {
356345 final sha = pullRequest.head! .sha! ;
346+ if (! isFusion) {
347+ unlockMergeGroup = true ;
348+ }
357349
358350 // Both the author and label should be checked to make sure that no one is
359351 // attempting to get a pull request without check through.
@@ -389,7 +381,7 @@ class Scheduler {
389381
390382 await _runCiTestingStage (
391383 pullRequest: pullRequest,
392- checkRunGuard: lock ? . toString () ?? ' ' ,
384+ checkRunGuard: '$ lock ' ,
393385 logCrumb: logCrumb,
394386
395387 // The if-branch already skips the engine build phase.
@@ -478,8 +470,8 @@ class Scheduler {
478470 // Normally the lock stays pending until the PR is ready to be enqueued, but
479471 // there are situations (see code above) when it needs to be unlocked
480472 // immediately.
481- if (lock != null && unlockMergeGroup) {
482- await _unlockMergeQueueGuard (slug, pullRequest.head! .sha! , lock);
473+ if (unlockMergeGroup) {
474+ await unlockMergeQueueGuard (slug, pullRequest.head! .sha! , lock);
483475 }
484476 log.info (
485477 'Finished triggering builds for: pr ${pullRequest .number }, commit ${pullRequest .base !.sha }, branch ${pullRequest .head !.ref } and slug $slug }' ,
@@ -596,12 +588,12 @@ class Scheduler {
596588 'triggerTargetsForMergeGroup($slug , $headSha , ${isFusion ? 'real' : 'simulated' })' ;
597589 log.info ('$logCrumb : scheduling merge group checks' );
598590
599- final lock = await _lockMergeGroupChecks (slug, headSha);
591+ final lock = await lockMergeGroupChecks (slug, headSha);
600592
601593 // If the repo is not fusion, it doesn't run anything in the MQ, so just
602594 // close the merge group guard.
603595 if (! isFusion) {
604- await _unlockMergeQueueGuard (slug, headSha, lock);
596+ await unlockMergeQueueGuard (slug, headSha, lock);
605597 return ;
606598 }
607599
794786 /// While this check is still in progress, the merge queue will not merge the
795787 /// respective PR onto the target branch (e.g. main or master), because this
796788 /// check is "required".
797- Future <CheckRun > _lockMergeGroupChecks (
789+ Future <CheckRun > lockMergeGroupChecks (
798790 RepositorySlug slug,
799791 String headSha,
800792 ) async {
818810 ///
819811 /// If the guard is guarding a pull request, this immediately makes the pull
820812 /// request eligible for enqueuing into the merge queue.
821- Future <void > _unlockMergeQueueGuard (
813+ Future <void > unlockMergeQueueGuard (
822814 RepositorySlug slug,
823815 String headSha,
824816 CheckRun lock,
@@ -1177,11 +1169,7 @@ $s
11771169 required String logCrumb,
11781170 }) async {
11791171 log.info ('$logCrumb : Stage completed: ${CiStage .fusionTests }' );
1180- await _unlockMergeQueueGuard (
1181- slug,
1182- sha,
1183- checkRunFromString (mergeQueueGuard),
1184- );
1172+ await unlockMergeQueueGuard (slug, sha, checkRunFromString (mergeQueueGuard));
11851173 }
11861174
11871175 /// Returns the presubmit targets for the fusion repo [pullRequest] that should run for the given [stage] .
12141202
12151203 // Unlock the guarding check_run.
12161204 final checkRunGuard = checkRunFromString (mergeQueueGuard);
1217- await _unlockMergeQueueGuard (slug, sha, checkRunGuard);
1205+ await unlockMergeQueueGuard (slug, sha, checkRunGuard);
12181206 }
12191207
12201208 /// Schedules post-engine build tests (i.e. engine tests, and framework tests).
0 commit comments