@@ -4,8 +4,10 @@ import type { GitLog } from '../../git/models/log';
44import type { GitReference } from '../../git/models/reference' ;
55import { createRevisionRange , getReferenceLabel , isRevisionReference } from '../../git/models/reference' ;
66import type { Repository } from '../../git/models/repository' ;
7+ import { showGenericErrorMessage } from '../../messages' ;
78import type { FlagsQuickPickItem } from '../../quickpicks/items/flags' ;
89import { createFlagsQuickPickItem } from '../../quickpicks/items/flags' ;
10+ import { Logger } from '../../system/logger' ;
911import type { ViewsWithRepositoryFolders } from '../../views/viewBase' ;
1012import type {
1113 PartialStepState ,
@@ -29,12 +31,15 @@ interface Context {
2931 title : string ;
3032}
3133
32- type Flags = '--edit' | '--no-commit' ;
34+ type CherryPickOptions = {
35+ noCommit ?: boolean ;
36+ edit ?: boolean ;
37+ } ;
3338
3439interface State < Refs = GitReference | GitReference [ ] > {
3540 repo : string | Repository ;
3641 references : Refs ;
37- flags : Flags [ ] ;
42+ options : CherryPickOptions ;
3843}
3944
4045export interface CherryPickGitCommandArgs {
@@ -80,8 +85,15 @@ export class CherryPickGitCommand extends QuickCommand<State> {
8085 return false ;
8186 }
8287
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+ }
8597 }
8698
8799 override isFuzzyMatch ( name : string ) {
@@ -99,8 +111,8 @@ export class CherryPickGitCommand extends QuickCommand<State> {
99111 title : this . title ,
100112 } ;
101113
102- if ( state . flags == null ) {
103- state . flags = [ ] ;
114+ if ( state . options == null ) {
115+ state . options = { } ;
104116 }
105117
106118 if ( state . references != null && ! Array . isArray ( state . references ) ) {
@@ -221,35 +233,35 @@ export class CherryPickGitCommand extends QuickCommand<State> {
221233 const result = yield * this . confirmStep ( state as CherryPickStepState , context ) ;
222234 if ( result === StepResultBreak ) continue ;
223235
224- state . flags = result ;
236+ state . options = Object . assign ( { } , ... result ) ;
225237 }
226238
227239 endSteps ( state ) ;
228- this . execute ( state as CherryPickStepState < State < GitReference [ ] > > ) ;
240+ await this . execute ( state as CherryPickStepState < State < GitReference [ ] > > ) ;
229241 }
230242
231243 return state . counter < 0 ? StepResultBreak : undefined ;
232244 }
233245
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 (
236248 appendReposToTitle ( `Confirm ${ context . title } ` , state , context ) ,
237249 [
238- createFlagsQuickPickItem < Flags > ( state . flags , [ ] , {
250+ createFlagsQuickPickItem < CherryPickOptions > ( [ ] , [ ] , {
239251 label : this . title ,
240252 detail : `Will apply ${ getReferenceLabel ( state . references , { label : false } ) } to ${ getReferenceLabel (
241253 context . destination ,
242254 { label : false } ,
243255 ) } `,
244256 } ) ,
245- createFlagsQuickPickItem < Flags > ( state . flags , [ '-- edit' ] , {
257+ createFlagsQuickPickItem < CherryPickOptions > ( [ ] , [ { edit : true } ] , {
246258 label : `${ this . title } & Edit` ,
247259 description : '--edit' ,
248260 detail : `Will edit and apply ${ getReferenceLabel ( state . references , {
249261 label : false ,
250262 } ) } to ${ getReferenceLabel ( context . destination , { label : false } ) } `,
251263 } ) ,
252- createFlagsQuickPickItem < Flags > ( state . flags , [ '--no-commit' ] , {
264+ createFlagsQuickPickItem < CherryPickOptions > ( [ ] , [ { noCommit : true } ] , {
253265 label : `${ this . title } without Committing` ,
254266 description : '--no-commit' ,
255267 detail : `Will apply ${ getReferenceLabel ( state . references , { label : false } ) } to ${ getReferenceLabel (
0 commit comments