fix(infra) - Add original PR number into hotfix branch (#10499)

Co-authored-by: Shi Shu <shii@google.com>
Co-authored-by: gemini-cli-robot <gemini-cli-robot@google.com>
This commit is contained in:
shishu314
2025-10-03 14:37:48 -04:00
committed by GitHub
parent 43b3f79d60
commit 0c61653b34
2 changed files with 20 additions and 11 deletions

View File

@@ -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)) {

View File

@@ -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
}