File tree Expand file tree Collapse file tree 1 file changed +14
-4
lines changed
Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -96,8 +96,9 @@ export function getRemoteBranches() {
9696export function isBranchPushedToRemote ( branchName ) {
9797 try {
9898 // Check if the branch exists on the remote
99- execSync ( `git ls-remote --heads origin ${ branchName } ` , { stdio : 'ignore' } ) ;
100- return true ;
99+ const output = execSync ( `git ls-remote --heads origin ${ branchName } ` ) . toString ( ) . trim ( ) ;
100+ // If output is empty, branch doesn't exist on remote
101+ return output . length > 0 ;
101102 } catch {
102103 return false ;
103104 }
@@ -300,9 +301,18 @@ export async function main() {
300301 // Check if branch is pushed to remote
301302 let needsToPush = false ;
302303 if ( ! isBranchPushedToRemote ( currentBranch ) ) {
303- console . log ( `\n🔄 Branch '${ currentBranch } ' not found on remote. Pushing now...` ) ;
304- needsToPush = true ;
304+ const shouldPush = await confirm ( {
305+ message : `Branch '${ currentBranch } ' not found on remote. Push to origin?` ,
306+ default : true
307+ } ) ;
305308
309+ if ( ! shouldPush ) {
310+ console . log ( '\n❌ Cannot create PR without pushing branch to remote.' ) ;
311+ return ;
312+ }
313+
314+ needsToPush = true ;
315+ console . log ( `\n🔄 Pushing branch '${ currentBranch } ' to remote...` ) ;
306316 const pushSucceeded = pushBranchToRemote ( currentBranch ) ;
307317 if ( ! pushSucceeded ) {
308318 console . error ( '\n❌ Failed to push branch to remote. Cannot create PR.' ) ;
You can’t perform that action at this time.
0 commit comments