@@ -165,6 +165,11 @@ function getStdinUniqueKey(): number {
165165type  ExitCodeOnlyGitCommandOptions  =  GitCommandOptions  &  {  exitCodeOnly : true  } ; 
166166export  type  PushForceOptions  =  {  withLease : true ;  ifIncludes ?: boolean  }  |  {  withLease : false ;  ifIncludes ?: never  } ; 
167167
168+ const  cherryPickErrorAndReason  =  [ 
169+ 	[ GitErrors . changesWouldBeOverwritten ,  CherryPickErrorReason . AbortedWouldOverwrite ] , 
170+ 	[ GitErrors . conflict ,  CherryPickErrorReason . Conflicts ] , 
171+ ] ; 
172+ 
168173const  tagErrorAndReason : [ RegExp ,  TagErrorReason ] [ ]  =  [ 
169174	[ GitErrors . tagAlreadyExists ,  TagErrorReason . TagAlreadyExists ] , 
170175	[ GitErrors . tagNotFound ,  TagErrorReason . TagNotFound ] , 
@@ -617,28 +622,18 @@ export class Git {
617622		return  this . git < string > ( {  cwd : repoPath  } ,  ...params ) ; 
618623	} 
619624
620- 	async  cherrypick ( repoPath : string ,  sha : string ,  options : {  noCommit ?: boolean ;  errors ?: GitErrorHandling  }  =  { } )  { 
621- 		const  params  =  [ 'cherry-pick' ] ; 
622- 		if  ( options ?. noCommit )  { 
623- 			params . push ( '-n' ) ; 
624- 		} 
625- 		params . push ( sha ) ; 
626- 
625+ 	async  cherryPick ( repoPath : string ,  args : string [ ] )  { 
627626		try  { 
628- 			await  this . git < string > ( {  cwd : repoPath ,   errors :  options ?. errors   } ,  ...params ) ; 
627+ 			await  this . git < string > ( {  cwd : repoPath   } ,  'cherry-pick' ,   ...args ) ; 
629628		}  catch  ( ex )  { 
630629			const  msg : string  =  ex ?. toString ( )  ??  '' ; 
631- 			let  reason : CherryPickErrorReason  =  CherryPickErrorReason . Other ; 
632- 			if  ( 
633- 				GitErrors . changesWouldBeOverwritten . test ( msg )  || 
634- 				GitErrors . changesWouldBeOverwritten . test ( ex . stderr  ??  '' ) 
635- 			)  { 
636- 				reason  =  CherryPickErrorReason . AbortedWouldOverwrite ; 
637- 			}  else  if  ( GitErrors . conflict . test ( msg )  ||  GitErrors . conflict . test ( ex . stdout  ??  '' ) )  { 
638- 				reason  =  CherryPickErrorReason . Conflicts ; 
630+ 			for  ( const  [ error ,  reason ]  of  cherryPickErrorAndReason )  { 
631+ 				if  ( error . test ( msg )  ||  error . test ( ex . stderr  ??  '' ) )  { 
632+ 					throw  new  CherryPickError ( reason ,  ex ) ; 
633+ 				} 
639634			} 
640635
641- 			throw  new  CherryPickError ( reason ,  ex ,   sha ) ; 
636+ 			throw  new  CherryPickError ( CherryPickErrorReason . Other ,  ex ) ; 
642637		} 
643638	} 
644639
0 commit comments