@@ -16,6 +16,11 @@ import * as fs from 'fs';
1616
1717import AWS from 'aws-sdk' ;
1818
19+ const CCERROR = '\x1b[31m%s\x1b[0m' ; // red
20+ const CCWARN = '\x1b[33m%s\x1b[0m' ; // yellow
21+ const CCINFO = '\x1b[36m%s\x1b[0m' ; // cyan
22+ const CCSUCCESS = '\x1b[32m%s\x1b[0m' ; // green
23+
1924const counters = {
2025 nrOfPlaceholderIssues : 0 ,
2126 nrOfReplacementIssues : 0 ,
@@ -331,6 +336,9 @@ async function transferMilestones(usePlaceholders: boolean) {
331336 */
332337async function transferLabels ( attachmentLabel = true , useLowerCase = true ) {
333338 inform ( 'Transferring Labels' ) ;
339+ console . warn ( CCWARN , 'NOTE (2022): GitHub descriptions are limited to 100 characters, and do not accept 4-byte Unicode' ) ;
340+
341+ const invalidUnicode = / [ \u{10000} - \u{10FFFF} ] | (? ! [ * # 0 - 9 ] + ) [ \p{ Emoji} \p{ Emoji_Modifier} \p{ Emoji_Component} \p{ Emoji_Modifier_Base} \p{ Emoji_Presentation} ] / gu;
334342
335343 // Get a list of all labels associated with this project
336344 let labels : SimpleLabel [ ] = await gitlabApi . Labels . all (
@@ -345,13 +353,15 @@ async function transferLabels(attachmentLabel = true, useLowerCase = true) {
345353 const hasAttachmentLabel = {
346354 name : 'has attachment' ,
347355 color : '#fbca04' ,
356+ description : 'Attachment was not transfered from GitLab' ,
348357 } ;
349358 labels . push ( hasAttachmentLabel ) ;
350359 }
351360
352361 const gitlabMergeRequestLabel = {
353362 name : 'gitlab merge request' ,
354363 color : '#b36b00' ,
364+ description : '' ,
355365 } ;
356366 labels . push ( gitlabMergeRequestLabel ) ;
357367
@@ -362,6 +372,28 @@ async function transferLabels(attachmentLabel = true, useLowerCase = true) {
362372
363373 if ( ! githubLabels . find ( l => l === label . name ) ) {
364374 console . log ( 'Creating: ' + label . name ) ;
375+
376+ if ( label . description ) {
377+ if ( label . description . match ( invalidUnicode ) ) {
378+ console . warn ( CCWARN , `⚠️ Removed invalid unicode characters from description.` ) ;
379+ const cleanedDescription = label . description . replace ( invalidUnicode , '' ) . trim ( ) ;
380+ console . debug ( ` "${ label . description } "\n\t to\n "${ cleanedDescription } "` ) ;
381+ label . description = cleanedDescription ;
382+ }
383+ if ( label . description . length > 100 ) {
384+ const trimmedDescription = label . description . slice ( 0 , 100 ) . trim ( ) ;
385+ if ( settings . trimOversizedLabelDescriptions ) {
386+ console . warn ( CCWARN , `⚠️ Description too long (${ label . description . length } ), it was trimmed:` ) ;
387+ console . debug ( ` "${ label . description } "\n\t to\n "${ trimmedDescription } "` ) ;
388+ label . description = trimmedDescription ;
389+ } else {
390+ console . warn ( CCWARN , `⚠️ Description too long (${ label . description . length } ), it was excluded.` ) ;
391+ console . debug ( ` "${ label . description } "` ) ;
392+ label . description = '' ;
393+ }
394+ }
395+ }
396+
365397 try {
366398 // process asynchronous code in sequence
367399 await githubHelper . createLabel ( label ) . catch ( x => { } ) ;
0 commit comments