@@ -331,7 +331,9 @@ async function transferMilestones(usePlaceholders: boolean) {
331331 */
332332async function transferLabels ( attachmentLabel = true , useLowerCase = true ) {
333333 inform ( 'Transferring Labels' ) ;
334- console . warn ( CCWARN , 'NOTE (2022): GitHub descriptions are limited to 100 characters!' ) ;
334+ console . warn ( CCWARN , 'NOTE (2022): GitHub descriptions are limited to 100 characters, and do not accept 4-byte Unicode' ) ;
335+
336+ const invalidUnicode = / [ \u{10000} - \u{10FFFF} ] / gu;
335337
336338 // Get a list of all labels associated with this project
337339 let labels : SimpleLabel [ ] = await gitlabApi . Labels . all (
@@ -366,15 +368,24 @@ async function transferLabels(attachmentLabel = true, useLowerCase = true) {
366368 if ( ! githubLabels . find ( l => l === label . name ) ) {
367369 console . log ( 'Creating: ' + label . name ) ;
368370
369- if ( label . description . length > 100 ) {
370- const trimmedDescription = label . description . slice ( 0 , 100 ) ;
371- if ( settings . trimOversizedLabelDescriptions ) {
372- console . warn ( CCWARN , `Description too long (${ label . description . length } ), it was trimmed: \n "${ label . description } "\n\t to\n "${ trimmedDescription } "` ) ;
373- label . description = trimmedDescription ;
374- } else {
375- console . warn ( CCWARN , `Description too long (${ label . description . length } ), it was excluded.` ) ;
376- console . debug ( ` "${ label . description } "` ) ;
377- label . description = '' ;
371+ if ( label . description ) {
372+ if ( label . description . match ( invalidUnicode ) ) {
373+ console . warn ( CCWARN , `⚠️ Removed invalid unicode characters from description.` ) ;
374+ const cleanedDescription = label . description . replace ( invalidUnicode , '' ) . trim ( ) ;
375+ console . debug ( ` "${ label . description } "\n\t to\n "${ cleanedDescription } "` ) ;
376+ label . description = cleanedDescription ;
377+ }
378+ if ( label . description . length > 100 ) {
379+ const trimmedDescription = label . description . slice ( 0 , 100 ) . trim ( ) ;
380+ if ( settings . trimOversizedLabelDescriptions ) {
381+ console . warn ( CCWARN , `⚠️ Description too long (${ label . description . length } ), it was trimmed:` ) ;
382+ console . debug ( ` "${ label . description } "\n\t to\n "${ trimmedDescription } "` ) ;
383+ label . description = trimmedDescription ;
384+ } else {
385+ console . warn ( CCWARN , `⚠️ Description too long (${ label . description . length } ), it was excluded.` ) ;
386+ console . debug ( ` "${ label . description } "` ) ;
387+ label . description = '' ;
388+ }
378389 }
379390 }
380391
0 commit comments