@@ -39,11 +39,13 @@ interface Context {
39
39
}
40
40
41
41
type Flags = '--interactive' ;
42
+ type RebaseOptions = { interactive ?: boolean } ;
42
43
43
44
interface State {
44
45
repo : string | Repository ;
45
46
destination : GitReference ;
46
47
flags : Flags [ ] ;
48
+ options : RebaseOptions ;
47
49
}
48
50
49
51
export interface RebaseGitCommandArgs {
@@ -82,13 +84,13 @@ export class RebaseGitCommand extends QuickCommand<State> {
82
84
83
85
async execute ( state : RebaseStepState ) {
84
86
const configs : { sequenceEditor ?: string } = { } ;
85
- if ( state . flags . includes ( '-- interactive' ) ) {
87
+ if ( state . options ?. interactive ) {
86
88
await this . container . rebaseEditor . enableForNextUse ( ) ;
87
89
configs . sequenceEditor = getEditorCommand ( ) ;
88
90
}
89
91
90
92
try {
91
- await state . repo . git . rebase ( state . destination . ref , configs , state . flags ) ;
93
+ await state . repo . git . rebase ( state . destination . ref , configs , state . options ) ;
92
94
} catch ( ex ) {
93
95
Logger . error ( ex , this . title ) ;
94
96
void showGenericErrorMessage ( ex ) ;
@@ -108,8 +110,8 @@ export class RebaseGitCommand extends QuickCommand<State> {
108
110
title : this . title ,
109
111
} ;
110
112
111
- if ( state . flags == null ) {
112
- state . flags = [ ] ;
113
+ if ( state . options == null ) {
114
+ state . options = { } ;
113
115
}
114
116
115
117
let skippedStepOne = false ;
@@ -212,7 +214,7 @@ export class RebaseGitCommand extends QuickCommand<State> {
212
214
const result = yield * this . confirmStep ( state as RebaseStepState , context ) ;
213
215
if ( result === StepResultBreak ) continue ;
214
216
215
- state . flags = result ;
217
+ state . options = Object . assign ( state . options ?? { } , ... result ) ;
216
218
217
219
endSteps ( state ) ;
218
220
void this . execute ( state as RebaseStepState ) ;
@@ -221,7 +223,7 @@ export class RebaseGitCommand extends QuickCommand<State> {
221
223
return state . counter < 0 ? StepResultBreak : undefined ;
222
224
}
223
225
224
- private async * confirmStep ( state : RebaseStepState , context : Context ) : AsyncStepResultGenerator < Flags [ ] > {
226
+ private async * confirmStep ( state : RebaseStepState , context : Context ) : AsyncStepResultGenerator < RebaseOptions [ ] > {
225
227
const counts = await this . container . git . getLeftRightCommitCount (
226
228
state . repo . path ,
227
229
createRevisionRange ( state . destination . ref , context . branch . ref , '...' ) ,
@@ -253,8 +255,9 @@ export class RebaseGitCommand extends QuickCommand<State> {
253
255
return StepResultBreak ;
254
256
}
255
257
258
+ const optionsArr : RebaseOptions [ ] = [ ] ;
256
259
const rebaseItems = [
257
- createFlagsQuickPickItem < Flags > ( state . flags , [ '-- interactive' ] , {
260
+ createFlagsQuickPickItem < RebaseOptions > ( optionsArr , [ { interactive : true } ] , {
258
261
label : `Interactive ${ this . title } ` ,
259
262
description : '--interactive' ,
260
263
detail : `Will interactively update ${ getReferenceLabel ( context . branch , {
@@ -267,7 +270,7 @@ export class RebaseGitCommand extends QuickCommand<State> {
267
270
268
271
if ( behind > 0 ) {
269
272
rebaseItems . unshift (
270
- createFlagsQuickPickItem < Flags > ( state . flags , [ ] , {
273
+ createFlagsQuickPickItem < RebaseOptions > ( optionsArr , [ { } ] , {
271
274
label : this . title ,
272
275
detail : `Will update ${ getReferenceLabel ( context . branch , {
273
276
label : false ,
@@ -278,10 +281,12 @@ export class RebaseGitCommand extends QuickCommand<State> {
278
281
) ;
279
282
}
280
283
281
- const step : QuickPickStep < FlagsQuickPickItem < Flags > > = this . createConfirmStep (
284
+ const step : QuickPickStep < FlagsQuickPickItem < RebaseOptions > > = this . createConfirmStep (
282
285
appendReposToTitle ( `Confirm ${ title } ` , state , context ) ,
283
286
rebaseItems ,
284
287
) ;
288
+
289
+ state . options = Object . assign ( state . options , ...optionsArr ) ;
285
290
const selection : StepSelection < typeof step > = yield step ;
286
291
return canPickStepContinue ( step , state , selection ) ? selection [ 0 ] . item : StepResultBreak ;
287
292
}
0 commit comments