@@ -4,8 +4,10 @@ import type { GitLog } from '../../git/models/log';
4
4
import type { GitReference } from '../../git/models/reference' ;
5
5
import { createRevisionRange , getReferenceLabel , isRevisionReference } from '../../git/models/reference' ;
6
6
import type { Repository } from '../../git/models/repository' ;
7
+ import { showGenericErrorMessage } from '../../messages' ;
7
8
import type { FlagsQuickPickItem } from '../../quickpicks/items/flags' ;
8
9
import { createFlagsQuickPickItem } from '../../quickpicks/items/flags' ;
10
+ import { Logger } from '../../system/logger' ;
9
11
import type { ViewsWithRepositoryFolders } from '../../views/viewBase' ;
10
12
import type {
11
13
PartialStepState ,
@@ -29,12 +31,15 @@ interface Context {
29
31
title : string ;
30
32
}
31
33
32
- type Flags = '--edit' | '--no-commit' ;
34
+ type CherryPickOptions = {
35
+ noCommit ?: boolean ;
36
+ edit ?: boolean ;
37
+ } ;
33
38
34
39
interface State < Refs = GitReference | GitReference [ ] > {
35
40
repo : string | Repository ;
36
41
references : Refs ;
37
- flags : Flags [ ] ;
42
+ options : CherryPickOptions ;
38
43
}
39
44
40
45
export interface CherryPickGitCommandArgs {
@@ -80,8 +85,15 @@ export class CherryPickGitCommand extends QuickCommand<State> {
80
85
return false ;
81
86
}
82
87
83
- execute ( state : CherryPickStepState < State < GitReference [ ] > > ) {
84
- state . repo . cherryPick ( ...state . flags , ...state . references . map ( c => c . ref ) . reverse ( ) ) ;
88
+ async execute ( state : CherryPickStepState < State < GitReference [ ] > > ) {
89
+ for ( const ref of state . references . map ( c => c . ref ) . reverse ( ) ) {
90
+ try {
91
+ await state . repo . git . cherryPick ( ref , state . options ) ;
92
+ } catch ( ex ) {
93
+ Logger . error ( ex , this . title ) ;
94
+ void showGenericErrorMessage ( ex . message ) ;
95
+ }
96
+ }
85
97
}
86
98
87
99
override isFuzzyMatch ( name : string ) {
@@ -99,8 +111,8 @@ export class CherryPickGitCommand extends QuickCommand<State> {
99
111
title : this . title ,
100
112
} ;
101
113
102
- if ( state . flags == null ) {
103
- state . flags = [ ] ;
114
+ if ( state . options == null ) {
115
+ state . options = { } ;
104
116
}
105
117
106
118
if ( state . references != null && ! Array . isArray ( state . references ) ) {
@@ -221,35 +233,35 @@ export class CherryPickGitCommand extends QuickCommand<State> {
221
233
const result = yield * this . confirmStep ( state as CherryPickStepState , context ) ;
222
234
if ( result === StepResultBreak ) continue ;
223
235
224
- state . flags = result ;
236
+ state . options = Object . assign ( { } , ... result ) ;
225
237
}
226
238
227
239
endSteps ( state ) ;
228
- this . execute ( state as CherryPickStepState < State < GitReference [ ] > > ) ;
240
+ await this . execute ( state as CherryPickStepState < State < GitReference [ ] > > ) ;
229
241
}
230
242
231
243
return state . counter < 0 ? StepResultBreak : undefined ;
232
244
}
233
245
234
- private * confirmStep ( state : CherryPickStepState , context : Context ) : StepResultGenerator < Flags [ ] > {
235
- const step : QuickPickStep < FlagsQuickPickItem < Flags > > = createConfirmStep (
246
+ private * confirmStep ( state : CherryPickStepState , context : Context ) : StepResultGenerator < CherryPickOptions [ ] > {
247
+ const step : QuickPickStep < FlagsQuickPickItem < CherryPickOptions > > = createConfirmStep (
236
248
appendReposToTitle ( `Confirm ${ context . title } ` , state , context ) ,
237
249
[
238
- createFlagsQuickPickItem < Flags > ( state . flags , [ ] , {
250
+ createFlagsQuickPickItem < CherryPickOptions > ( [ ] , [ ] , {
239
251
label : this . title ,
240
252
detail : `Will apply ${ getReferenceLabel ( state . references , { label : false } ) } to ${ getReferenceLabel (
241
253
context . destination ,
242
254
{ label : false } ,
243
255
) } `,
244
256
} ) ,
245
- createFlagsQuickPickItem < Flags > ( state . flags , [ '-- edit' ] , {
257
+ createFlagsQuickPickItem < CherryPickOptions > ( [ ] , [ { edit : true } ] , {
246
258
label : `${ this . title } & Edit` ,
247
259
description : '--edit' ,
248
260
detail : `Will edit and apply ${ getReferenceLabel ( state . references , {
249
261
label : false ,
250
262
} ) } to ${ getReferenceLabel ( context . destination , { label : false } ) } `,
251
263
} ) ,
252
- createFlagsQuickPickItem < Flags > ( state . flags , [ '--no-commit' ] , {
264
+ createFlagsQuickPickItem < CherryPickOptions > ( [ ] , [ { noCommit : true } ] , {
253
265
label : `${ this . title } without Committing` ,
254
266
description : '--no-commit' ,
255
267
detail : `Will apply ${ getReferenceLabel ( state . references , { label : false } ) } to ${ getReferenceLabel (
0 commit comments