@@ -633,70 +633,62 @@ import {fsStat} from '../lib/helpers';
633
633
{
634
634
command : 'commit' ,
635
635
progressiveTense : 'committing' ,
636
+ usesPromptServerAlready : false ,
636
637
action : ( ) => git . commit ( 'message' ) ,
637
638
} ,
638
639
{
639
640
command : 'merge' ,
640
641
progressiveTense : 'merging' ,
642
+ usesPromptServerAlready : false ,
641
643
action : ( ) => git . merge ( 'some-branch' ) ,
642
644
} ,
643
645
{
644
646
command : 'pull' ,
645
647
progressiveTense : 'pulling' ,
648
+ usesPromptServerAlready : true ,
646
649
action : ( ) => git . pull ( 'some-branch' ) ,
647
650
} ,
648
651
] ;
649
652
650
653
operations . forEach ( op => {
651
654
it ( `temporarily overrides gpg.program when ${ op . progressiveTense } ` , async function ( ) {
652
- const execStub = sinon . stub ( git , 'exec' ) ;
653
- if ( op . configureStub ) {
654
- op . configureStub ( git ) ;
655
- }
656
- execStub . returns ( Promise . resolve ( ) ) ;
655
+ const execStub = sinon . stub ( GitProcess , 'exec' ) ;
656
+ execStub . returns ( Promise . resolve ( { stdout : '' , stderr : '' , exitCode : 0 } ) ) ;
657
657
658
658
await op . action ( ) ;
659
659
660
- const callArgs = execStub . getCall ( 0 ) . args ;
661
- const execArgs = callArgs [ 0 ] ;
662
- assert . equal ( execArgs [ 0 ] , '-c' ) ;
663
- assert . match ( execArgs [ 1 ] , / ^ g p g \. p r o g r a m = .* g p g - n o - t t y \. s h $ / ) ;
664
- assert . isNotOk ( callArgs [ 1 ] . stdin ) ;
665
- assert . isNotOk ( callArgs [ 1 ] . useGitPromptServer ) ;
666
- } ) ;
660
+ const [ args , workingDir , options ] = execStub . getCall ( 0 ) . args ;
667
661
668
- it ( `retries a ${ op . command } with a GitPromptServer when GPG signing fails` , async function ( ) {
669
- const gpgErr = new GitError ( 'Mock GPG failure' ) ;
670
- gpgErr . stdErr = 'stderr includes "gpg failed"' ;
671
- gpgErr . code = 128 ;
662
+ assertGitConfigSetting ( args , op . command , 'gpg.program' , '.*gpg-no-tty\\.sh$' ) ;
672
663
673
- const execStub = sinon . stub ( git , 'exec' ) ;
674
- if ( op . configureStub ) {
675
- op . configureStub ( execStub , git ) ;
676
- }
677
- execStub . onCall ( 0 ) . returns ( Promise . reject ( gpgErr ) ) ;
678
- execStub . returns ( Promise . resolve ( ) ) ;
664
+ assert . equal ( options . env . ATOM_GITHUB_SOCK_PATH === undefined , ! op . usesPromptServerAlready ) ;
665
+ assert . equal ( workingDir , git . workingDir ) ;
666
+ } ) ;
679
667
680
- try {
668
+ if ( ! op . usesPromptServerAlready ) {
669
+ it ( `retries a ${ op . command } with a GitPromptServer when GPG signing fails` , async function ( ) {
670
+ const execStub = sinon . stub ( GitProcess , 'exec' ) ;
671
+ execStub . onCall ( 0 ) . returns ( Promise . resolve ( {
672
+ stdout : '' ,
673
+ stderr : 'stderr includes "gpg failed"' ,
674
+ exitCode : 128 ,
675
+ } ) ) ;
676
+ execStub . returns ( Promise . resolve ( { stdout : '' , stderr : '' , exitCode : 0 } ) ) ;
677
+
678
+ // Should not throw
681
679
await op . action ( ) ;
682
- } catch ( err ) {
683
- assert . fail ( 'expected op.action() not to throw the mock error' ) ;
684
- }
685
680
686
- const callArgs0 = execStub . getCall ( 0 ) . args ;
687
- const execArgs0 = callArgs0 [ 0 ] ;
688
- assert . equal ( execArgs0 [ 0 ] , '-c' ) ;
689
- assert . match ( execArgs0 [ 1 ] , / ^ g p g \. p r o g r a m = .* g p g - n o - t t y \. s h $ / ) ;
690
- assert . isNotOk ( callArgs0 [ 1 ] . stdin ) ;
691
- assert . isNotOk ( callArgs0 [ 1 ] . useGitPromptServer ) ;
692
-
693
- const callArgs1 = execStub . getCall ( 0 + 1 ) . args ;
694
- const execArgs1 = callArgs1 [ 0 ] ;
695
- assert . equal ( execArgs1 [ 0 ] , '-c' ) ;
696
- assert . match ( execArgs1 [ 1 ] , / ^ g p g \. p r o g r a m = .* g p g - n o - t t y \. s h $ / ) ;
697
- assert . isNotOk ( callArgs1 [ 1 ] . stdin ) ;
698
- assert . isTrue ( callArgs1 [ 1 ] . useGitPromptServer ) ;
699
- } ) ;
681
+ const [ args0 , workingDir0 , options0 ] = execStub . getCall ( 0 ) . args ;
682
+ assertGitConfigSetting ( args0 , op . command , 'gpg.program' , '.*gpg-no-tty\\.sh$' ) ;
683
+ assert . equal ( options0 . env . ATOM_GITHUB_SOCK_PATH === undefined , ! op . usesPromptServerAlready ) ;
684
+ assert . equal ( workingDir0 , git . workingDir ) ;
685
+
686
+ const [ args1 , workingDir1 , options1 ] = execStub . getCall ( 1 ) . args ;
687
+ assertGitConfigSetting ( args1 , op . command , 'gpg.program' , '.*gpg-no-tty\\.sh$' ) ;
688
+ assert . isDefined ( options1 . env . ATOM_GITHUB_SOCK_PATH ) ;
689
+ assert . equal ( workingDir1 , git . workingDir ) ;
690
+ } ) ;
691
+ }
700
692
} ) ;
701
693
} ) ;
702
694
0 commit comments