@@ -571,7 +571,7 @@ export function registerCommands(
571571 return { folderManager, pr } ;
572572 } ;
573573
574- const applyPullRequestChanges = async ( folderManager : FolderRepositoryManager , pullRequest : PullRequestModel ) : Promise < void > => {
574+ const applyPullRequestChanges = async ( task : vscode . Progress < { message ?: string ; increment ?: number ; } > , folderManager : FolderRepositoryManager , pullRequest : PullRequestModel ) : Promise < void > => {
575575 let patch : string | undefined ;
576576 try {
577577 patch = await pullRequest . getPatch ( ) ;
@@ -589,22 +589,13 @@ export function registerCommands(
589589 const encoder = new TextEncoder ( ) ;
590590 const tempUri = vscode . Uri . file ( tempFilePath ) ;
591591
592- await vscode . window . withProgress (
593- {
594- location : vscode . ProgressLocation . Notification ,
595- title : vscode . l10n . t ( 'Applying changes from pull request #{0}' , pullRequest . number . toString ( ) ) ,
596- cancellable : false
597- } ,
598- async ( task ) => {
599- await vscode . workspace . fs . writeFile ( tempUri , encoder . encode ( patch ) ) ;
600- try {
601- await folderManager . repository . apply ( tempFilePath , false ) ;
602- task . report ( { message : vscode . l10n . t ( 'Successfully applied changes from pull request #{0}' , pullRequest . number . toString ( ) ) , increment : 100 } ) ;
603- } finally {
604- await vscode . workspace . fs . delete ( tempUri ) ;
605- }
606- }
607- ) ;
592+ await vscode . workspace . fs . writeFile ( tempUri , encoder . encode ( patch ) ) ;
593+ try {
594+ await folderManager . repository . apply ( tempFilePath , false ) ;
595+ task . report ( { message : vscode . l10n . t ( 'Successfully applied changes from pull request #{0}' , pullRequest . number . toString ( ) ) , increment : 100 } ) ;
596+ } finally {
597+ await vscode . workspace . fs . delete ( tempUri ) ;
598+ }
608599
609600 } catch ( error ) {
610601 const errorMessage = formatError ( error ) ;
@@ -672,21 +663,44 @@ export function registerCommands(
672663 if ( Number . isNaN ( prNumber ) ) {
673664 return vscode . window . showErrorMessage ( vscode . l10n . t ( 'Unable to parse pull request number.' ) ) ;
674665 }
675- const folderManager = reposManager . folderManagers [ 0 ] ;
676- const pullRequest = await folderManager . fetchById ( folderManager . gitHubRepositories [ 0 ] , Number ( prNumber ) ) ;
677- if ( ! pullRequest ) {
678- return vscode . window . showErrorMessage ( vscode . l10n . t ( 'Unable to find pull request #{0}' , prNumber . toString ( ) ) ) ;
679- }
680666
681- return applyPullRequestChanges ( folderManager , pullRequest ) ;
682- }
667+ await vscode . window . withProgress (
668+ {
669+ location : vscode . ProgressLocation . Notification ,
670+ title : vscode . l10n . t ( 'Applying changes from pull request #{0}' , prNumber . toString ( ) ) ,
671+ cancellable : false
672+ } ,
673+ async ( task ) => {
674+ task . report ( { increment : 30 } ) ;
683675
684- const resolved = await resolvePr ( ctx ) ;
685- if ( ! resolved ) {
686- return vscode . window . showErrorMessage ( vscode . l10n . t ( 'Unable to resolve pull request for applying changes.' ) ) ;
676+ const folderManager = reposManager . folderManagers [ 0 ] ;
677+ const pullRequest = await folderManager . fetchById ( folderManager . gitHubRepositories [ 0 ] , Number ( prNumber ) ) ;
678+ if ( ! pullRequest ) {
679+ return vscode . window . showErrorMessage ( vscode . l10n . t ( 'Unable to find pull request #{0}' , prNumber . toString ( ) ) ) ;
680+ }
681+
682+ return applyPullRequestChanges ( task , folderManager , pullRequest ) ;
683+ } ) ;
684+
685+ return ;
687686 }
688- return applyPullRequestChanges ( resolved . folderManager , resolved . pr ) ;
689687
688+ await vscode . window . withProgress (
689+ {
690+ location : vscode . ProgressLocation . Notification ,
691+ title : vscode . l10n . t ( 'Applying changes from pull request' ) ,
692+ cancellable : false
693+ } ,
694+ async ( task ) => {
695+ task . report ( { increment : 30 } ) ;
696+
697+ const resolved = await resolvePr ( ctx ) ;
698+ if ( ! resolved ) {
699+ return vscode . window . showErrorMessage ( vscode . l10n . t ( 'Unable to resolve pull request for applying changes.' ) ) ;
700+ }
701+ return applyPullRequestChanges ( task , resolved . folderManager , resolved . pr ) ;
702+ }
703+ ) ;
690704 } ) ) ;
691705
692706 context . subscriptions . push (
0 commit comments