Skip to content

Commit 49e77f2

Browse files
committed
fix: always retry with API-returned base branch (not just when different)
1 parent 3e70f09 commit 49e77f2

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

scripts/github-code-review.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -432,22 +432,22 @@ function processJob(array $job): string
432432
return 'shutdown';
433433
}
434434
$actualBaseBranch = getPRBaseBranch($repo, $prNumber);
435-
if ($actualBaseBranch !== null && $actualBaseBranch !== $baseBranch) {
436-
verbose_log("retrying with actual base branch: {$actualBaseBranch}", 2);
437-
$checkoutOk = checkoutBranch($repo, $actualBaseBranch, $checkoutPath);
438-
if ($checkoutOk === 'shutdown') {
439-
verbose_log("shutdown during fallback checkout, abandoning job", 2);
440-
return 'shutdown';
441-
}
435+
if ($actualBaseBranch === null) {
436+
verbose_log("could not determine actual base branch from API", 1);
437+
return 'checkout failed: could not look up base branch';
438+
}
439+
verbose_log("retrying with actual base branch: {$actualBaseBranch}", 2);
440+
$checkoutOk = checkoutBranch($repo, $actualBaseBranch, $checkoutPath);
441+
if ($checkoutOk === 'shutdown') {
442+
verbose_log("shutdown during fallback checkout, abandoning job", 2);
443+
return 'shutdown';
442444
}
443445
if ($checkoutOk !== 'true') {
444446
verbose_log("checkout failed: {$checkoutOk}", 1);
445447
return 'checkout failed: ' . $checkoutOk;
446448
}
447449
// Update baseBranch for later use (e.g., diff application)
448-
if (isset($actualBaseBranch)) {
449-
$baseBranch = $actualBaseBranch;
450-
}
450+
$baseBranch = $actualBaseBranch;
451451
}
452452
verbose_log("checkout complete: base branch checked out", 2);
453453

0 commit comments

Comments
 (0)