Skip to content

Commit 4e8d844

Browse files
committed
Oversized description + added some console color
1 parent 69fa91a commit 4e8d844

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

sample_settings.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ export default {
4848
useReplacementIssuesForCreationFails: true,
4949
useIssuesForAllMergeRequests: false,
5050
filterByLabel: null,
51+
trimOversizedLabelDescriptions: false,
5152
skipMergeRequestStates: [],
5253
skipMatchingComments: [],
5354
mergeRequests: {

src/index.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ import * as fs from 'fs';
1616

1717
import 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+
1924
const counters = {
2025
nrOfPlaceholderIssues: 0,
2126
nrOfReplacementIssues: 0,
@@ -326,6 +331,7 @@ async function transferMilestones(usePlaceholders: boolean) {
326331
*/
327332
async function transferLabels(attachmentLabel = true, useLowerCase = true) {
328333
inform('Transferring Labels');
334+
console.warn(CCWARN,'NOTE (2022): GitHub descriptions are limited to 100 characters!');
329335

330336
// Get a list of all labels associated with this project
331337
let labels: SimpleLabel[] = await gitlabApi.Labels.all(
@@ -359,6 +365,19 @@ async function transferLabels(attachmentLabel = true, useLowerCase = true) {
359365

360366
if (!githubLabels.find(l => l === label.name)) {
361367
console.log('Creating: ' + label.name);
368+
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 = '';
378+
}
379+
}
380+
362381
try {
363382
// process asynchronous code in sequence
364383
await githubHelper.createLabel(label).catch(x => {});

src/settings.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export default interface Settings {
2525
useReplacementIssuesForCreationFails: boolean;
2626
useIssuesForAllMergeRequests: boolean;
2727
filterByLabel?: string;
28+
trimOversizedLabelDescriptions: boolean;
2829
skipMergeRequestStates: string[];
2930
skipMatchingComments: string[];
3031
mergeRequests: {

0 commit comments

Comments
 (0)