@@ -787,18 +787,18 @@ func TestClientReadBranchConfig(t *testing.T) {
787787 Stdout : "branch.trunk.remote origin\n " ,
788788 },
789789 `path/to/git config remote.pushDefault` : {
790- Stdout : "pushdefault " ,
790+ Stdout : "remotePushDefault " ,
791791 },
792792 `path/to/git rev-parse --verify --quiet --abbrev-ref trunk@{push}` : {
793793 Stdout : "origin/trunk" ,
794794 },
795795 },
796796 branch : "trunk" ,
797797 wantBranchConfig : BranchConfig {
798- RemoteName : "origin" ,
799- PushRemoteName : "pushdefault " ,
800- Push : "origin/trunk" ,
801- PushDefaultName : "pushdefault " ,
798+ RemoteName : "origin" ,
799+ PushRemoteName : "remotePushDefault " ,
800+ Push : "origin/trunk" ,
801+ RemotePushDefault : "remotePushDefault " ,
802802 },
803803 wantError : nil ,
804804 },
@@ -809,57 +809,36 @@ func TestClientReadBranchConfig(t *testing.T) {
809809 Stdout : "branch.trunk.remote origin\n " ,
810810 },
811811 `path/to/git config remote.pushDefault` : {
812- Stdout : "pushdefault " ,
812+ Stdout : "remotePushDefault " ,
813813 },
814814 `path/to/git rev-parse --verify --quiet --abbrev-ref trunk@{push}` : {
815815 ExitStatus : 1 ,
816816 },
817817 },
818818 branch : "trunk" ,
819819 wantBranchConfig : BranchConfig {
820- RemoteName : "origin" ,
821- PushRemoteName : "pushdefault " ,
822- PushDefaultName : "pushdefault " ,
820+ RemoteName : "origin" ,
821+ PushRemoteName : "remotePushDefault " ,
822+ RemotePushDefault : "remotePushDefault " ,
823823 },
824824 wantError : nil ,
825825 },
826826 {
827- name : "when git reads the config, pushDefault is set, and rev-parse fails, it should return an empty BranchConfig and the error" ,
827+ name : "when git reads the config but remotePushDefault fails, it should return and empty BranchConfig and the error" ,
828828 cmds : mockedCommands {
829829 `path/to/git config --get-regexp ^branch\.trunk\.(remote|merge|pushremote|gh-merge-base)$` : {
830830 Stdout : "branch.trunk.remote origin\n " ,
831831 },
832832 `path/to/git config remote.pushDefault` : {
833- Stdout : "pushdefault" ,
834- },
835- `path/to/git rev-parse --verify --quiet --abbrev-ref trunk@{push}` : {
836833 ExitStatus : 2 ,
837- Stderr : "rev-parse error" ,
834+ Stderr : "remotePushDefault error" ,
838835 },
839836 },
840837 branch : "trunk" ,
841838 wantBranchConfig : BranchConfig {},
842839 wantError : & GitError {
843840 ExitCode : 2 ,
844- Stderr : "rev-parse error" ,
845- },
846- },
847- {
848- name : "when git reads the config but pushdefault fails, it should return and empty BranchConfig and the error" ,
849- cmds : mockedCommands {
850- `path/to/git config --get-regexp ^branch\.trunk\.(remote|merge|pushremote|gh-merge-base)$` : {
851- Stdout : "branch.trunk.remote origin\n " ,
852- },
853- `path/to/git config remote.pushDefault` : {
854- ExitStatus : 2 ,
855- Stderr : "pushdefault error" ,
856- },
857- },
858- branch : "trunk" ,
859- wantBranchConfig : BranchConfig {},
860- wantError : & GitError {
861- ExitCode : 2 ,
862- Stderr : "pushdefault error" ,
841+ Stderr : "remotePushDefault error" ,
863842 },
864843 },
865844 {
@@ -963,11 +942,11 @@ func TestClientReadBranchConfig(t *testing.T) {
963942 },
964943 branch : "trunk" ,
965944 wantBranchConfig : BranchConfig {
966- RemoteName : "upstream" ,
967- MergeRef : "refs/heads/main" ,
968- PushRemoteName : "origin" ,
969- Push : "origin/trunk" ,
970- PushDefaultName : "origin" ,
945+ RemoteName : "upstream" ,
946+ MergeRef : "refs/heads/main" ,
947+ PushRemoteName : "origin" ,
948+ Push : "origin/trunk" ,
949+ RemotePushDefault : "origin" ,
971950 },
972951 },
973952 {
@@ -985,10 +964,10 @@ func TestClientReadBranchConfig(t *testing.T) {
985964 },
986965 branch : "trunk" ,
987966 wantBranchConfig : BranchConfig {
988- RemoteName : "upstream" ,
989- MergeRef : "refs/heads/main" ,
990- PushRemoteName : "origin" ,
991- PushDefaultName : "current" ,
967+ RemoteName : "upstream" ,
968+ MergeRef : "refs/heads/main" ,
969+ PushRemoteName : "origin" ,
970+ RemotePushDefault : "current" ,
992971 },
993972 },
994973 {
@@ -1006,10 +985,10 @@ func TestClientReadBranchConfig(t *testing.T) {
1006985 },
1007986 branch : "trunk" ,
1008987 wantBranchConfig : BranchConfig {
1009- RemoteName : "upstream" ,
1010- MergeRef : "refs/heads/main" ,
1011- PushRemoteName : "origin" ,
1012- PushDefaultName : "origin" ,
988+ RemoteName : "upstream" ,
989+ MergeRef : "refs/heads/main" ,
990+ PushRemoteName : "origin" ,
991+ RemotePushDefault : "origin" ,
1013992 },
1014993 },
1015994 }
@@ -1021,15 +1000,15 @@ func TestClientReadBranchConfig(t *testing.T) {
10211000 commandContext : cmdCtx ,
10221001 }
10231002 branchConfig , err := client .ReadBranchConfig (context .Background (), tt .branch )
1024- assert .Equal (t , tt .wantBranchConfig , branchConfig )
10251003 if tt .wantError != nil {
10261004 var gitError * GitError
10271005 require .ErrorAs (t , err , & gitError )
10281006 assert .Equal (t , tt .wantError .ExitCode , gitError .ExitCode )
10291007 assert .Equal (t , tt .wantError .Stderr , gitError .Stderr )
10301008 } else {
1031- assert .NoError (t , err )
1009+ require .NoError (t , err )
10321010 }
1011+ assert .Equal (t , tt .wantBranchConfig , branchConfig )
10331012 })
10341013 }
10351014}
@@ -1082,10 +1061,10 @@ func Test_parseBranchConfig(t *testing.T) {
10821061 {
10831062 name : "push default specified" ,
10841063 configLines : []string {},
1085- pushDefault : "pushdefault " ,
1064+ pushDefault : "remotePushDefault " ,
10861065 wantBranchConfig : BranchConfig {
1087- PushRemoteName : "pushdefault " ,
1088- PushDefaultName : "pushdefault " ,
1066+ PushRemoteName : "remotePushDefault " ,
1067+ RemotePushDefault : "remotePushDefault " ,
10891068 },
10901069 },
10911070 {
@@ -1128,15 +1107,15 @@ func Test_parseBranchConfig(t *testing.T) {
11281107 "branch.trunk.gh-merge-base gh-merge-base" ,
11291108 "branch.trunk.merge refs/heads/trunk" ,
11301109 },
1131- pushDefault : "pushdefault " ,
1110+ pushDefault : "remotePushDefault " ,
11321111 revParse : "origin/trunk" ,
11331112 wantBranchConfig : BranchConfig {
1134- RemoteName : "remote" ,
1135- PushRemoteName : "pushremote" ,
1136- MergeBase : "gh-merge-base" ,
1137- MergeRef : "refs/heads/trunk" ,
1138- Push : "origin/trunk" ,
1139- PushDefaultName : "pushdefault " ,
1113+ RemoteName : "remote" ,
1114+ PushRemoteName : "pushremote" ,
1115+ MergeBase : "gh-merge-base" ,
1116+ MergeRef : "refs/heads/trunk" ,
1117+ Push : "origin/trunk" ,
1118+ RemotePushDefault : "remotePushDefault " ,
11401119 },
11411120 },
11421121 {
@@ -1158,7 +1137,7 @@ func Test_parseBranchConfig(t *testing.T) {
11581137 assert .Equalf (t , tt .wantBranchConfig .MergeBase , branchConfig .MergeBase , "unexpected MergeBase" )
11591138 assert .Equalf (t , tt .wantBranchConfig .PushRemoteName , branchConfig .PushRemoteName , "unexpected PushRemoteName" )
11601139 assert .Equalf (t , tt .wantBranchConfig .Push , branchConfig .Push , "unexpected Push" )
1161- assert .Equalf (t , tt .wantBranchConfig .PushDefaultName , branchConfig .PushDefaultName , "unexpected PushDefaultName " )
1140+ assert .Equalf (t , tt .wantBranchConfig .RemotePushDefault , branchConfig .RemotePushDefault , "unexpected RemotePushDefault " )
11621141 if tt .wantBranchConfig .RemoteURL != nil {
11631142 assert .Equalf (t , tt .wantBranchConfig .RemoteURL .String (), branchConfig .RemoteURL .String (), "unexpected RemoteURL" )
11641143 }
0 commit comments