@@ -118,7 +118,9 @@ func syncGitConfig(ctx context.Context) (err error) {
118
118
}
119
119
120
120
func configSet (ctx context.Context , key , value string ) error {
121
- stdout , _ , err := gitcmd .NewCommand ("config" , "--global" , "--get" ).AddDynamicArguments (key ).RunStdString (ctx , nil )
121
+ stdout , _ , err := gitcmd .NewCommand ("config" , "--global" , "--get" ).
122
+ AddDynamicArguments (key ).
123
+ RunStdString (ctx )
122
124
if err != nil && ! gitcmd .IsErrorExitCode (err , 1 ) {
123
125
return fmt .Errorf ("failed to get git config %s, err: %w" , key , err )
124
126
}
@@ -128,23 +130,24 @@ func configSet(ctx context.Context, key, value string) error {
128
130
return nil
129
131
}
130
132
131
- _ , _ , err = gitcmd .NewCommand ("config" , "--global" ).AddDynamicArguments (key , value ).RunStdString (ctx , nil )
132
- if err != nil {
133
+ if _ , _ , err = gitcmd .NewCommand ("config" , "--global" ).
134
+ AddDynamicArguments (key , value ).
135
+ RunStdString (ctx ); err != nil {
133
136
return fmt .Errorf ("failed to set git global config %s, err: %w" , key , err )
134
137
}
135
138
136
139
return nil
137
140
}
138
141
139
142
func configSetNonExist (ctx context.Context , key , value string ) error {
140
- _ , _ , err := gitcmd .NewCommand ("config" , "--global" , "--get" ).AddDynamicArguments (key ).RunStdString (ctx , nil )
143
+ _ , _ , err := gitcmd .NewCommand ("config" , "--global" , "--get" ).AddDynamicArguments (key ).RunStdString (ctx )
141
144
if err == nil {
142
145
// already exist
143
146
return nil
144
147
}
145
148
if gitcmd .IsErrorExitCode (err , 1 ) {
146
149
// not exist, set new config
147
- _ , _ , err = gitcmd .NewCommand ("config" , "--global" ).AddDynamicArguments (key , value ).RunStdString (ctx , nil )
150
+ _ , _ , err = gitcmd .NewCommand ("config" , "--global" ).AddDynamicArguments (key , value ).RunStdString (ctx )
148
151
if err != nil {
149
152
return fmt .Errorf ("failed to set git global config %s, err: %w" , key , err )
150
153
}
@@ -155,14 +158,14 @@ func configSetNonExist(ctx context.Context, key, value string) error {
155
158
}
156
159
157
160
func configAddNonExist (ctx context.Context , key , value string ) error {
158
- _ , _ , err := gitcmd .NewCommand ("config" , "--global" , "--get" ).AddDynamicArguments (key , regexp .QuoteMeta (value )).RunStdString (ctx , nil )
161
+ _ , _ , err := gitcmd .NewCommand ("config" , "--global" , "--get" ).AddDynamicArguments (key , regexp .QuoteMeta (value )).RunStdString (ctx )
159
162
if err == nil {
160
163
// already exist
161
164
return nil
162
165
}
163
166
if gitcmd .IsErrorExitCode (err , 1 ) {
164
167
// not exist, add new config
165
- _ , _ , err = gitcmd .NewCommand ("config" , "--global" , "--add" ).AddDynamicArguments (key , value ).RunStdString (ctx , nil )
168
+ _ , _ , err = gitcmd .NewCommand ("config" , "--global" , "--add" ).AddDynamicArguments (key , value ).RunStdString (ctx )
166
169
if err != nil {
167
170
return fmt .Errorf ("failed to add git global config %s, err: %w" , key , err )
168
171
}
@@ -172,10 +175,10 @@ func configAddNonExist(ctx context.Context, key, value string) error {
172
175
}
173
176
174
177
func configUnsetAll (ctx context.Context , key , value string ) error {
175
- _ , _ , err := gitcmd .NewCommand ("config" , "--global" , "--get" ).AddDynamicArguments (key ).RunStdString (ctx , nil )
178
+ _ , _ , err := gitcmd .NewCommand ("config" , "--global" , "--get" ).AddDynamicArguments (key ).RunStdString (ctx )
176
179
if err == nil {
177
180
// exist, need to remove
178
- _ , _ , err = gitcmd .NewCommand ("config" , "--global" , "--unset-all" ).AddDynamicArguments (key , regexp .QuoteMeta (value )).RunStdString (ctx , nil )
181
+ _ , _ , err = gitcmd .NewCommand ("config" , "--global" , "--unset-all" ).AddDynamicArguments (key , regexp .QuoteMeta (value )).RunStdString (ctx )
179
182
if err != nil {
180
183
return fmt .Errorf ("failed to unset git global config %s, err: %w" , key , err )
181
184
}
0 commit comments