in src/github/operations/branch.ts [94:122]
async function createNewBranch(baseBranch: string, branchName: string, prBaseBranch: string | undefined) {
// Normalize branch name: lowercase and limit to 50 chars for git compatibility
const newBranch = branchName.toLowerCase().substring(0, 50);
try {
console.log(`Creating new branch ${newBranch} from ${baseBranch}`);
await $`git checkout --no-track -b ${newBranch} origin/${baseBranch}`;
console.log(`✓ Successfully created and checked out new branch: ${newBranch}`);
return {
baseBranch: baseBranch,
workingBranch: newBranch,
isNewBranch: true,
prBaseBranch
};
} catch (error) {
console.error(`❌ Failed to create branch "${newBranch}" from "${baseBranch}":`, error);
throw new Error(
`❌ Failed to create working branch "${newBranch}" from base branch "${baseBranch}". ` +
`This could be due to:\n` +
`• Base branch "${baseBranch}" does not exist in the repository\n` +
`• Insufficient permissions to fetch from the repository\n` +
`• Network connectivity issues\n` +
`• Git authentication problems\n` +
`Original error: ${error instanceof Error ? error.message : String(error)}`
);
}
}