This commit is contained in:
matt korwel
2025-09-18 10:45:42 -07:00
committed by GitHub
parent b88d9c6353
commit b376df7691
2 changed files with 32 additions and 25 deletions

View File

@@ -62,7 +62,25 @@ async function main() {
// Check if hotfix branch already exists
if (branchExists(hotfixBranch)) {
console.log(`Hotfix branch ${hotfixBranch} already exists.`);
return { existingBranch: hotfixBranch };
// Check if there's already a PR for this branch
try {
const prInfo = execSync(`gh pr list --head ${hotfixBranch} --json number,url --jq '.[0] // empty'`).toString().trim();
if (prInfo && prInfo !== 'null' && prInfo !== '') {
const pr = JSON.parse(prInfo);
console.log(`Found existing PR #${pr.number}: ${pr.url}`);
console.log(`Hotfix branch ${hotfixBranch} already has an open PR.`);
return { existingBranch: hotfixBranch, existingPR: pr };
} else {
console.log(`Hotfix branch ${hotfixBranch} exists but has no open PR.`);
console.log(`You may need to delete the branch and run this command again.`);
return { existingBranch: hotfixBranch };
}
} catch (err) {
console.error(`Error checking for existing PR: ${err.message}`);
console.log(`Hotfix branch ${hotfixBranch} already exists.`);
return { existingBranch: hotfixBranch };
}
}
// Create the hotfix branch from the release branch.