@@ -517,29 +517,19 @@ export class Git {
517
517
await this . git < string > ( { cwd : repoPath } , 'branch' , ...args ) ;
518
518
} catch ( ex ) {
519
519
const msg : string = ex ?. toString ( ) ?? '' ;
520
- let reason : BranchErrorReason = BranchErrorReason . Other ;
521
- switch ( true ) {
522
- case GitErrors . noRemoteReference . test ( msg ) || GitErrors . noRemoteReference . test ( ex . stderr ?? '' ) :
523
- reason = BranchErrorReason . NoRemoteReference ;
524
- break ;
525
- case GitErrors . invalidBranchName . test ( msg ) || GitErrors . invalidBranchName . test ( ex . stderr ?? '' ) :
526
- reason = BranchErrorReason . InvalidBranchName ;
527
- break ;
528
- case GitErrors . branchAlreadyExists . test ( msg ) || GitErrors . branchAlreadyExists . test ( ex . stderr ?? '' ) :
529
- reason = BranchErrorReason . BranchAlreadyExists ;
530
- break ;
531
- case GitErrors . branchNotFullyMerged . test ( msg ) || GitErrors . branchNotFullyMerged . test ( ex . stderr ?? '' ) :
532
- reason = BranchErrorReason . BranchNotFullyMerged ;
533
- break ;
534
- case GitErrors . branchNotYetBorn . test ( msg ) || GitErrors . branchNotYetBorn . test ( ex . stderr ?? '' ) :
535
- reason = BranchErrorReason . BranchNotYetBorn ;
536
- break ;
537
- case GitErrors . branchFastForwardRejected . test ( msg ) ||
538
- GitErrors . branchFastForwardRejected . test ( ex . stderr ?? '' ) :
539
- reason = BranchErrorReason . BranchFastForwardRejected ;
540
- break ;
520
+ for ( const [ error , reason ] of [
521
+ [ GitErrors . noRemoteReference , BranchErrorReason . NoRemoteReference ] ,
522
+ [ GitErrors . invalidBranchName , BranchErrorReason . InvalidBranchName ] ,
523
+ [ GitErrors . branchAlreadyExists , BranchErrorReason . BranchAlreadyExists ] ,
524
+ [ GitErrors . branchNotFullyMerged , BranchErrorReason . BranchNotFullyMerged ] ,
525
+ [ GitErrors . branchNotYetBorn , BranchErrorReason . BranchNotYetBorn ] ,
526
+ [ GitErrors . branchFastForwardRejected , BranchErrorReason . BranchFastForwardRejected ] ,
527
+ ] ) {
528
+ if ( error . test ( msg ) || error . test ( ex . stderr ?? '' ) ) {
529
+ throw new BranchError ( reason , ex ) ;
530
+ }
541
531
}
542
- throw new BranchError ( reason , ex ) ;
532
+ throw new BranchError ( BranchErrorReason . Other , ex ) ;
543
533
}
544
534
}
545
535
@@ -1024,9 +1014,9 @@ export class Git {
1024
1014
} else {
1025
1015
params . push ( options . remote , options . branch ) ;
1026
1016
}
1027
- } else if ( options . remote != null ) {
1017
+ } else if ( options . remote ) {
1028
1018
params . push ( options . remote ) ;
1029
- } else if ( options . delete != null ) {
1019
+ } else if ( options . delete ) {
1030
1020
params . push ( '-d' , options . delete . remote , ...options . delete . branches ) ;
1031
1021
}
1032
1022
0 commit comments