mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-02-01 22:48:03 +00:00
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:
@@ -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)) {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user