@@ -250,6 +250,7 @@ func upsertGitHubRepo(repo map[string]interface{}, mirrorConfigUsed MirrorDefini
250
250
path := githubNameFromGitlabPath (repo ["fullPath" ].(string ), mirrorConfigUsed )
251
251
252
252
description := fmt .Sprintf ("%.250s (mirror)" , repo ["description" ])
253
+ description = strings .ReplaceAll (description , "\r \n " , " " )
253
254
description = strings .ReplaceAll (description , "\n " , " " )
254
255
255
256
checkUrl := fmt .Sprintf ("https://github.com/%s/%s" , githubOrg , path )
@@ -261,6 +262,8 @@ func upsertGitHubRepo(repo map[string]interface{}, mirrorConfigUsed MirrorDefini
261
262
client := & http.Client {}
262
263
var req * http.Request
263
264
265
+ // For debugging when an error occurs
266
+ var jsonBodyString string
264
267
if resp .StatusCode == 200 {
265
268
ll .Log ("Updating" , "cyan" , "%s/%s" , githubOrg , path )
266
269
url := fmt .Sprintf ("https://api.github.com/repos/%s/%s" , githubOrg , path )
@@ -270,6 +273,7 @@ func upsertGitHubRepo(repo map[string]interface{}, mirrorConfigUsed MirrorDefini
270
273
"homepage" : repo ["webUrl" ],
271
274
}
272
275
jsonBody , _ := json .Marshal (reqBody )
276
+ jsonBodyString = string (jsonBody )
273
277
274
278
req , err = http .NewRequest ("PATCH" , url , bytes .NewBuffer (jsonBody ))
275
279
if err != nil {
@@ -285,6 +289,7 @@ func upsertGitHubRepo(repo map[string]interface{}, mirrorConfigUsed MirrorDefini
285
289
"homepage" : repo ["webUrl" ],
286
290
}
287
291
jsonBody , _ := json .Marshal (reqBody )
292
+ jsonBodyString = string (jsonBody )
288
293
289
294
req , err = http .NewRequest ("POST" , url , bytes .NewBuffer (jsonBody ))
290
295
if err != nil {
@@ -305,8 +310,7 @@ func upsertGitHubRepo(repo map[string]interface{}, mirrorConfigUsed MirrorDefini
305
310
306
311
if resp .StatusCode >= 400 {
307
312
respBody , _ := io .ReadAll (resp .Body )
308
- reqBody , _ := io .ReadAll (req .Body )
309
- return "" , fmt .Errorf ("GitHub API error: %s: %s: for request: %s" , resp .Status , respBody , reqBody )
313
+ return "" , fmt .Errorf ("GitHub API error: %s: %s: for request: %s" , resp .Status , respBody , jsonBodyString )
310
314
}
311
315
312
316
return path , nil
0 commit comments