@@ -16,6 +16,11 @@ import * as fs from 'fs';
16
16
17
17
import AWS from 'aws-sdk' ;
18
18
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
+
19
24
const counters = {
20
25
nrOfPlaceholderIssues : 0 ,
21
26
nrOfReplacementIssues : 0 ,
@@ -331,6 +336,9 @@ async function transferMilestones(usePlaceholders: boolean) {
331
336
*/
332
337
async function transferLabels ( attachmentLabel = true , useLowerCase = true ) {
333
338
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;
334
342
335
343
// Get a list of all labels associated with this project
336
344
let labels : SimpleLabel [ ] = await gitlabApi . Labels . all (
@@ -345,13 +353,15 @@ async function transferLabels(attachmentLabel = true, useLowerCase = true) {
345
353
const hasAttachmentLabel = {
346
354
name : 'has attachment' ,
347
355
color : '#fbca04' ,
356
+ description : 'Attachment was not transfered from GitLab' ,
348
357
} ;
349
358
labels . push ( hasAttachmentLabel ) ;
350
359
}
351
360
352
361
const gitlabMergeRequestLabel = {
353
362
name : 'gitlab merge request' ,
354
363
color : '#b36b00' ,
364
+ description : '' ,
355
365
} ;
356
366
labels . push ( gitlabMergeRequestLabel ) ;
357
367
@@ -362,6 +372,28 @@ async function transferLabels(attachmentLabel = true, useLowerCase = true) {
362
372
363
373
if ( ! githubLabels . find ( l => l === label . name ) ) {
364
374
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
+
365
397
try {
366
398
// process asynchronous code in sequence
367
399
await githubHelper . createLabel ( label ) . catch ( x => { } ) ;
0 commit comments