@@ -1376,7 +1376,42 @@ Don't forget to commit your template file to the repository so that it can be us
13761376 const compareRepositoryName = message . args . compareRepo ;
13771377 const compareBranchName = message . args . compareBranch ;
13781378 const compareGithubRemoteName = `${ compareOwner } /${ compareRepositoryName } ` ;
1379- const compareBranch = await this . _folderRepositoryManager . repository . getBranch ( compareBranchName ) ;
1379+ let compareBranch = await this . _folderRepositoryManager . repository . getBranch ( compareBranchName ) ;
1380+
1381+ // Fetch upstream to get accurate ahead/behind count
1382+ if ( compareBranch . upstream ) {
1383+ await this . _folderRepositoryManager . repository . fetch ( compareBranch . upstream . remote , compareBranch . upstream . name ) ;
1384+ // Re-fetch branch info after fetch to get accurate ahead count
1385+ compareBranch = await this . _folderRepositoryManager . repository . getBranch ( compareBranchName ) ;
1386+ }
1387+
1388+ // Check for unpushed commits when there's an upstream
1389+ if ( compareBranch . upstream && compareBranch . ahead && compareBranch . ahead > 0 ) {
1390+ const pushCommits = vscode . l10n . t ( 'Push Commits' ) ;
1391+ const continueWithoutPushing = vscode . l10n . t ( 'Continue Without Pushing' ) ;
1392+ const commitCount = compareBranch . ahead ;
1393+ const messageResult = await vscode . window . showInformationMessage (
1394+ vscode . l10n . t ( {
1395+ message : 'You have {0} unpushed commit(s) on \'{1}\'.\n\nDo you want to push them before creating the pull request?' ,
1396+ comment : [ '{0} is the number of commits, {1} is the branch name' ] ,
1397+ args : [ commitCount , compareBranchName ]
1398+ } ) ,
1399+ { modal : true } ,
1400+ pushCommits ,
1401+ continueWithoutPushing
1402+ ) ;
1403+ if ( messageResult === pushCommits ) {
1404+ progress . report ( { message : vscode . l10n . t ( 'Pushing commits' ) , increment : 10 } ) ;
1405+ totalIncrement += 10 ;
1406+ await this . _folderRepositoryManager . repository . push ( compareBranch . upstream . remote , compareBranchName ) ;
1407+ } else if ( messageResult !== continueWithoutPushing ) {
1408+ // User cancelled (clicked X or pressed Escape)
1409+ progress . report ( { message : vscode . l10n . t ( 'Pull request cancelled' ) , increment : 100 - totalIncrement } ) ;
1410+ return ;
1411+ }
1412+ // If continueWithoutPushing was selected, just continue with PR creation
1413+ }
1414+
13801415 let headRepo = compareBranch . upstream ? this . _folderRepositoryManager . findRepo ( ( githubRepo ) => {
13811416 return ( githubRepo . remote . owner === compareOwner ) && ( githubRepo . remote . repositoryName === compareRepositoryName ) ;
13821417 } ) : undefined ;
0 commit comments