@@ -32,13 +32,11 @@ interface Context {
3232 title : string ;
3333}
3434
35- type Flags = '--edit' | '--no-edit' ;
3635type RevertOptions = { edit ?: boolean } ;
3736
3837interface State < Refs = GitRevisionReference | GitRevisionReference [ ] > {
3938 repo : string | Repository ;
4039 references : Refs ;
41- flags : Flags [ ] ;
4240 options : RevertOptions ;
4341}
4442
@@ -83,28 +81,16 @@ export class RevertGitCommand extends QuickCommand<State> {
8381 try {
8482 await state . repo . git . revert ( ref . ref , state . options ) ;
8583 } catch ( ex ) {
86- if ( ex instanceof RevertError ) {
87- let shouldRetry = false ;
88- if ( ex . reason === RevertErrorReason . LocalChangesWouldBeOverwritten ) {
89- const response = await showShouldCommitOrStashPrompt ( ) ;
90- if ( response === 'Stash' ) {
91- await executeCommand ( Commands . GitCommandsStashPush ) ;
92- shouldRetry = true ;
93- } else if ( response === 'Commit' ) {
94- await executeCoreCommand ( 'workbench.view.scm' ) ;
95- shouldRetry = true ;
96- } else {
97- continue ;
98- }
84+ if ( RevertError . is ( ex , RevertErrorReason . LocalChangesWouldBeOverwritten ) ) {
85+ const response = await showShouldCommitOrStashPrompt ( ) ;
86+ if ( response == null || response === 'Cancel' ) {
87+ continue ;
9988 }
10089
101- if ( shouldRetry ) {
102- try {
103- await state . repo . git . revert ( ref . ref , state . flags ) ;
104- } catch ( ex ) {
105- Logger . error ( ex , this . title ) ;
106- void showGenericErrorMessage ( ex . message ) ;
107- }
90+ if ( response === 'Stash' ) {
91+ await executeCommand ( Commands . GitCommandsStashPush ) ;
92+ } else if ( response === 'Commit' ) {
93+ await executeCoreCommand ( 'workbench.view.scm' ) ;
10894 }
10995
11096 continue ;
@@ -125,8 +111,8 @@ export class RevertGitCommand extends QuickCommand<State> {
125111 title : this . title ,
126112 } ;
127113
128- if ( state . flags == null ) {
129- state . flags = [ ] ;
114+ if ( state . options == null ) {
115+ state . options = { } ;
130116 }
131117
132118 if ( state . references != null && ! Array . isArray ( state . references ) ) {
@@ -208,23 +194,21 @@ export class RevertGitCommand extends QuickCommand<State> {
208194 }
209195
210196 private * confirmStep ( state : RevertStepState , context : Context ) : StepResultGenerator < RevertOptions [ ] > {
211- const optionsArr : RevertOptions [ ] = [ ] ;
212197 const step : QuickPickStep < FlagsQuickPickItem < RevertOptions > > = this . createConfirmStep (
213198 appendReposToTitle ( `Confirm ${ context . title } ` , state , context ) ,
214199 [
215- createFlagsQuickPickItem < RevertOptions > ( optionsArr , [ { edit : false } ] , {
200+ createFlagsQuickPickItem < RevertOptions > ( [ ] , [ { edit : false } ] , {
216201 label : this . title ,
217202 description : '--no-edit' ,
218203 detail : `Will revert ${ getReferenceLabel ( state . references ) } ` ,
219204 } ) ,
220- createFlagsQuickPickItem < RevertOptions > ( optionsArr , [ { edit : true } ] , {
205+ createFlagsQuickPickItem < RevertOptions > ( [ ] , [ { edit : true } ] , {
221206 label : `${ this . title } & Edit` ,
222207 description : '--edit' ,
223208 detail : `Will revert and edit ${ getReferenceLabel ( state . references ) } ` ,
224209 } ) ,
225210 ] ,
226211 ) ;
227- state . options = Object . assign ( { } , ...optionsArr ) ;
228212 const selection : StepSelection < typeof step > = yield step ;
229213 return canPickStepContinue ( step , state , selection ) ? selection [ 0 ] . item : StepResultBreak ;
230214 }
0 commit comments