@@ -561,7 +561,7 @@ func TestGitCommandUpstreamDifferentCount(t *testing.T) {
561
561
{
562
562
"Can't retrieve pullable count" ,
563
563
func (cmd string , args ... string ) * exec.Cmd {
564
- if args [1 ] == "head ..@{u}" {
564
+ if args [1 ] == "HEAD ..@{u}" {
565
565
return exec .Command ("test" )
566
566
}
567
567
@@ -575,7 +575,7 @@ func TestGitCommandUpstreamDifferentCount(t *testing.T) {
575
575
{
576
576
"Retrieve pullable and pushable count" ,
577
577
func (cmd string , args ... string ) * exec.Cmd {
578
- if args [1 ] == "head ..@{u}" {
578
+ if args [1 ] == "HEAD ..@{u}" {
579
579
return exec .Command ("echo" , "10" )
580
580
}
581
581
@@ -889,7 +889,76 @@ func TestGitCommandCommit(t *testing.T) {
889
889
gitCmd := newDummyGitCommand ()
890
890
gitCmd .getGlobalGitConfig = s .getGlobalGitConfig
891
891
gitCmd .OSCommand .command = s .command
892
- s .test (gitCmd .Commit ("test" ))
892
+ s .test (gitCmd .Commit ("test" , false ))
893
+ })
894
+ }
895
+ }
896
+
897
+ func TestGitCommandCommitAmendFromFiles (t * testing.T ) {
898
+ type scenario struct {
899
+ testName string
900
+ command func (string , ... string ) * exec.Cmd
901
+ getGlobalGitConfig func (string ) (string , error )
902
+ test func (* exec.Cmd , error )
903
+ }
904
+
905
+ scenarios := []scenario {
906
+ {
907
+ "Amend commit using gpg" ,
908
+ func (cmd string , args ... string ) * exec.Cmd {
909
+ assert .EqualValues (t , "bash" , cmd )
910
+ assert .EqualValues (t , []string {"-c" , `git commit --amend -m 'test'` }, args )
911
+
912
+ return exec .Command ("echo" )
913
+ },
914
+ func (string ) (string , error ) {
915
+ return "true" , nil
916
+ },
917
+ func (cmd * exec.Cmd , err error ) {
918
+ assert .NotNil (t , cmd )
919
+ assert .Nil (t , err )
920
+ },
921
+ },
922
+ {
923
+ "Amend commit without using gpg" ,
924
+ func (cmd string , args ... string ) * exec.Cmd {
925
+ assert .EqualValues (t , "git" , cmd )
926
+ assert .EqualValues (t , []string {"commit" , "--amend" , "-m" , "test" }, args )
927
+
928
+ return exec .Command ("echo" )
929
+ },
930
+ func (string ) (string , error ) {
931
+ return "false" , nil
932
+ },
933
+ func (cmd * exec.Cmd , err error ) {
934
+ assert .Nil (t , cmd )
935
+ assert .Nil (t , err )
936
+ },
937
+ },
938
+ {
939
+ "Amend commit without using gpg with an error" ,
940
+ func (cmd string , args ... string ) * exec.Cmd {
941
+ assert .EqualValues (t , "git" , cmd )
942
+ assert .EqualValues (t , []string {"commit" , "--amend" , "-m" , "test" }, args )
943
+
944
+ return exec .Command ("test" )
945
+ },
946
+ func (string ) (string , error ) {
947
+ return "false" , nil
948
+ },
949
+ func (cmd * exec.Cmd , err error ) {
950
+ assert .Nil (t , cmd )
951
+ assert .Error (t , err )
952
+ },
953
+ },
954
+ }
955
+
956
+ for _ , s := range scenarios {
957
+ t .Run (s .testName , func (t * testing.T ) {
958
+ gitCmd := newDummyGitCommand ()
959
+ gitCmd .getGlobalGitConfig = s .getGlobalGitConfig
960
+ gitCmd .OSCommand .command = s .command
961
+ s .test (gitCmd .Commit ("test" , true ))
893
962
})
894
963
}
895
964
}
@@ -1507,7 +1576,7 @@ func TestGitCommandGetCommits(t *testing.T) {
1507
1576
1508
1577
switch args [0 ] {
1509
1578
case "rev-list" :
1510
- assert .EqualValues (t , []string {"rev-list" , "@{u}..head " , "--abbrev-commit" }, args )
1579
+ assert .EqualValues (t , []string {"rev-list" , "@{u}..HEAD " , "--abbrev-commit" }, args )
1511
1580
return exec .Command ("echo" )
1512
1581
case "log" :
1513
1582
assert .EqualValues (t , []string {"log" , "--oneline" , "-30" }, args )
@@ -1534,7 +1603,7 @@ func TestGitCommandGetCommits(t *testing.T) {
1534
1603
1535
1604
switch args [0 ] {
1536
1605
case "rev-list" :
1537
- assert .EqualValues (t , []string {"rev-list" , "@{u}..head " , "--abbrev-commit" }, args )
1606
+ assert .EqualValues (t , []string {"rev-list" , "@{u}..HEAD " , "--abbrev-commit" }, args )
1538
1607
return exec .Command ("echo" , "8a2bb0e" )
1539
1608
case "log" :
1540
1609
assert .EqualValues (t , []string {"log" , "--oneline" , "-30" }, args )
@@ -1577,7 +1646,7 @@ func TestGitCommandGetCommits(t *testing.T) {
1577
1646
1578
1647
switch args [0 ] {
1579
1648
case "rev-list" :
1580
- assert .EqualValues (t , []string {"rev-list" , "@{u}..head " , "--abbrev-commit" }, args )
1649
+ assert .EqualValues (t , []string {"rev-list" , "@{u}..HEAD " , "--abbrev-commit" }, args )
1581
1650
return exec .Command ("echo" , "8a2bb0e" )
1582
1651
case "log" :
1583
1652
assert .EqualValues (t , []string {"log" , "--oneline" , "-30" }, args )
0 commit comments