@@ -425,6 +425,8 @@ export class PullRequestOverviewPanel extends IssueOverviewPanel<PullRequestMode
425425 return this . openCommitChanges ( message ) ;
426426 case 'pr.delete-review' :
427427 return this . deleteReview ( message ) ;
428+ case 'pr.change-base-branch' :
429+ return this . changeBaseBranch ( message ) ;
428430 }
429431 }
430432
@@ -805,6 +807,59 @@ export class PullRequestOverviewPanel extends IssueOverviewPanel<PullRequestMode
805807 }
806808 }
807809
810+ private async changeBaseBranch ( message : IRequestMessage < void > ) : Promise < void > {
811+ const quickPick = vscode . window . createQuickPick < vscode . QuickPickItem & { branch ?: string } > ( ) ;
812+
813+ try {
814+ quickPick . busy = true ;
815+ quickPick . canSelectMany = false ;
816+ quickPick . placeholder = 'Select a new base branch' ;
817+ quickPick . show ( ) ;
818+
819+ // List branches from the repository
820+ const branches = await this . _item . githubRepository . listBranches (
821+ this . _item . remote . owner ,
822+ this . _item . remote . repositoryName
823+ ) ;
824+
825+ quickPick . items = branches
826+ . filter ( branch => branch !== this . _item . base . name )
827+ . map ( branch => ( {
828+ label : branch ,
829+ branch : branch
830+ } ) ) ;
831+
832+ quickPick . busy = false ;
833+ const acceptPromise = asPromise < void > ( quickPick . onDidAccept ) . then ( ( ) => {
834+ return quickPick . selectedItems [ 0 ] ?. branch ;
835+ } ) ;
836+ const hidePromise = asPromise < void > ( quickPick . onDidHide ) ;
837+ const selectedBranch = await Promise . race < string | void > ( [ acceptPromise , hidePromise ] ) ;
838+ quickPick . busy = true ;
839+ quickPick . enabled = false ;
840+
841+ if ( selectedBranch ) {
842+ try {
843+ // Update the base branch using GraphQL mutation
844+ await this . _item . updateBaseBranch ( selectedBranch ) ;
845+ // Refresh the panel to reflect the changes
846+ await this . refreshPanel ( ) ;
847+ await this . _replyMessage ( message , { } ) ;
848+ } catch ( e ) {
849+ Logger . error ( formatError ( e ) , PullRequestOverviewPanel . ID ) ;
850+ vscode . window . showErrorMessage ( vscode . l10n . t ( 'Changing base branch failed. {0}' , formatError ( e ) ) ) ;
851+ this . _throwError ( message , `${ formatError ( e ) } ` ) ;
852+ }
853+ }
854+ } catch ( e ) {
855+ Logger . error ( formatError ( e ) , PullRequestOverviewPanel . ID ) ;
856+ vscode . window . showErrorMessage ( formatError ( e ) ) ;
857+ } finally {
858+ quickPick . hide ( ) ;
859+ quickPick . dispose ( ) ;
860+ }
861+ }
862+
808863 override dispose ( ) {
809864 super . dispose ( ) ;
810865 disposeAll ( this . _prListeners ) ;
0 commit comments