diff --git a/scripts/releasing/create-patch-pr.js b/scripts/releasing/create-patch-pr.js index e614f7b316..767cee7fa9 100644 --- a/scripts/releasing/create-patch-pr.js +++ b/scripts/releasing/create-patch-pr.js @@ -53,7 +53,7 @@ async function main() { const nextVersion = releaseInfo.nextVersion; const releaseBranch = `release/${latestTag}-pr-${pullRequestNumber}`; - const hotfixBranch = `hotfix/${latestTag}/${nextVersion}/${channel}/cherry-pick-${commit.substring(0, 7)}`; + const hotfixBranch = `hotfix/${latestTag}/${nextVersion}/${channel}/cherry-pick-${commit.substring(0, 7)}/pr-${pullRequestNumber}`; // Create the release branch from the tag if it doesn't exist. if (!branchExists(releaseBranch)) { diff --git a/scripts/releasing/patch-trigger.js b/scripts/releasing/patch-trigger.js index d7fcb013f5..2780301412 100644 --- a/scripts/releasing/patch-trigger.js +++ b/scripts/releasing/patch-trigger.js @@ -15,9 +15,9 @@ import yargs from 'yargs'; import { hideBin } from 'yargs/helpers'; /** - * Extract base version and channel info from hotfix branch name. Branches can - * be in multiple formats: - * - New NEW: hotfix/v0.5.3/v0.5.4/preview/cherry-pick-abc -> v0.5.4 and preview + * Extract base version, original pr, and originalPr info from hotfix branch name. + * Formats: + * - New NEW: hotfix/v0.5.3/v0.5.4/preview/cherry-pick-abc/pr-1234 -> v0.5.4, preview, 1234 * - New format: hotfix/v0.5.3/preview/cherry-pick-abc -> v0.5.3 and preview * - Old format: hotfix/v0.5.3/cherry-pick-abc -> v0.5.3 and stable (default) * We check the formats from newest to oldest. If the channel found is invalid, @@ -26,9 +26,12 @@ import { hideBin } from 'yargs/helpers'; function getBranchInfo({ branchName, context }) { const parts = branchName.split('/'); const version = parts[1]; + let prNum; let channel = 'stable'; // default for old format - if (parts.length >= 5 && (parts[3] === 'stable' || parts[3] === 'preview')) { + if (parts.length >= 6 && (parts[3] === 'stable' || parts[3] === 'preview')) { channel = parts[3]; + const prMatch = parts[5].match(/pr-(\d+)/); + prNum = prMatch[1]; } else if ( parts.length >= 4 && (parts[2] === 'stable' || parts[2] === 'preview') @@ -47,7 +50,7 @@ function getBranchInfo({ branchName, context }) { ); } - return { channel, version }; + return { channel, prNum, version }; } async function main() { @@ -115,11 +118,16 @@ async function main() { console.log(`Processing patch trigger for branch: ${headRef}`); - const { version, channel } = getBranchInfo({ branchName: headRef, context }); + const { prNum, version, channel } = getBranchInfo({ + branchName: headRef, + context, + }); - // Try to find the original PR that requested this patch - let originalPr = null; - if (!testMode) { + let originalPr = prNum; + console.log(`Found originalPr: ${prNum} from hotfix branch`); + + // Fallback to using PR search (inconsistent) if no pr found in branch name. + if (!testMode && !originalPr) { try { console.log('Looking for original PR using search...'); const { execFileSync } = await import('node:child_process'); @@ -159,7 +167,8 @@ async function main() { } catch (e) { console.log('Could not determine original PR:', e.message); } - } else { + } + if (!originalPr && testMode) { console.log('Skipping original PR lookup (test mode)'); originalPr = 8655; // Mock for testing }