@@ -32,13 +32,11 @@ interface Context {
32
32
title : string ;
33
33
}
34
34
35
- type Flags = '--edit' | '--no-edit' ;
36
35
type RevertOptions = { edit ?: boolean } ;
37
36
38
37
interface State < Refs = GitRevisionReference | GitRevisionReference [ ] > {
39
38
repo : string | Repository ;
40
39
references : Refs ;
41
- flags : Flags [ ] ;
42
40
options : RevertOptions ;
43
41
}
44
42
@@ -83,28 +81,16 @@ export class RevertGitCommand extends QuickCommand<State> {
83
81
try {
84
82
await state . repo . git . revert ( ref . ref , state . options ) ;
85
83
} 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 ;
99
88
}
100
89
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' ) ;
108
94
}
109
95
110
96
continue ;
@@ -125,8 +111,8 @@ export class RevertGitCommand extends QuickCommand<State> {
125
111
title : this . title ,
126
112
} ;
127
113
128
- if ( state . flags == null ) {
129
- state . flags = [ ] ;
114
+ if ( state . options == null ) {
115
+ state . options = { } ;
130
116
}
131
117
132
118
if ( state . references != null && ! Array . isArray ( state . references ) ) {
@@ -208,23 +194,21 @@ export class RevertGitCommand extends QuickCommand<State> {
208
194
}
209
195
210
196
private * confirmStep ( state : RevertStepState , context : Context ) : StepResultGenerator < RevertOptions [ ] > {
211
- const optionsArr : RevertOptions [ ] = [ ] ;
212
197
const step : QuickPickStep < FlagsQuickPickItem < RevertOptions > > = this . createConfirmStep (
213
198
appendReposToTitle ( `Confirm ${ context . title } ` , state , context ) ,
214
199
[
215
- createFlagsQuickPickItem < RevertOptions > ( optionsArr , [ { edit : false } ] , {
200
+ createFlagsQuickPickItem < RevertOptions > ( [ ] , [ { edit : false } ] , {
216
201
label : this . title ,
217
202
description : '--no-edit' ,
218
203
detail : `Will revert ${ getReferenceLabel ( state . references ) } ` ,
219
204
} ) ,
220
- createFlagsQuickPickItem < RevertOptions > ( optionsArr , [ { edit : true } ] , {
205
+ createFlagsQuickPickItem < RevertOptions > ( [ ] , [ { edit : true } ] , {
221
206
label : `${ this . title } & Edit` ,
222
207
description : '--edit' ,
223
208
detail : `Will revert and edit ${ getReferenceLabel ( state . references ) } ` ,
224
209
} ) ,
225
210
] ,
226
211
) ;
227
- state . options = Object . assign ( { } , ...optionsArr ) ;
228
212
const selection : StepSelection < typeof step > = yield step ;
229
213
return canPickStepContinue ( step , state , selection ) ? selection [ 0 ] . item : StepResultBreak ;
230
214
}
0 commit comments