Skip to content

Commit 3918aba

Browse files
committed
fix(prepare): skip PR sync when there are zero updates and no changes to push
When no packages need updating, the release branch is identical to the default branch. Previously we still called syncPullRequest, which attempted to create a PR and hit a GitHub 422 ("No commits between main and release/next"). Now we bail out early with a clear log message and return null instead.
1 parent 1878df3 commit 3918aba

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/workflows/prepare.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,18 @@ export async function prepareWorkflow(options: NormalizedReleaseScriptsOptions):
253253
}
254254

255255
if (!hasChangesToPush.value) {
256+
// When there are no updates at all, the release branch is identical to the
257+
// default branch. Attempting to create/update a PR would fail with a 422
258+
// ("No commits between main and <release-branch>"), so bail out early.
259+
if (allUpdates.length === 0) {
260+
logger.info("No changes to commit and no packages to release. Nothing to do.");
261+
const checkoutResult = await checkoutBranch(options.branch.default, options.workspaceRoot);
262+
if (!checkoutResult.ok) {
263+
exitWithError(`Failed to checkout branch: ${options.branch.default}`, undefined, checkoutResult.error);
264+
}
265+
return null;
266+
}
267+
256268
const prResult = await syncPullRequest({
257269
github: options.githubClient,
258270
releaseBranch: options.branch.release,

0 commit comments

Comments
 (0)