Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
timotheeguerin committed May 11, 2024
1 parent 1531813 commit 5bf631c
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions eng/common/scripts/sync-labels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,15 @@ function logLabels(message: string, labels: Label[]) {
console.log(message);
const max = labels.reduce((max, label) => Math.max(max, label.name.length), 0);
for (const label of labels) {
console.log(
` ${pc.cyan(label.name.padEnd(max))} ${pc.blue(`#${label.color}`)} ${pc.gray(label.description)}`
);
console.log(` ${prettyLabel(label, max)}`);
}
console.log("");
}

function prettyLabel(label: Label, padEnd: number = 0) {
return `${pc.cyan(label.name.padEnd(padEnd))} ${pc.blue(`#${label.color}`)} ${pc.gray(label.description)}`;
}

interface UpdateGithubLabelOptions {
readonly dryRun?: boolean;
}
Expand All @@ -65,7 +67,7 @@ async function updateGithubLabels(labels: Label[], options: UpdateGithubLabelOpt
);

const existingLabels = await fetchAllLabels(octokit);
logLabels("Existing labels", existingLabels as any);
logLabels("Existing github labels", existingLabels as any);
const labelToUpdate: Label[] = [];
const labelsToCreate: Label[] = [];
const exitingLabelMap = new Map(existingLabels.map((label) => [label.name, label]));
Expand All @@ -81,8 +83,8 @@ async function updateGithubLabels(labels: Label[], options: UpdateGithubLabelOpt
exitingLabelMap.delete(label.name);
}
const labelsToDelete = Array.from(exitingLabelMap.values()).map((x) => x.name);
console.log("Labels to update", labelToUpdate);
console.log("Labels to create", labelsToCreate);
logLabels("Labels to update", labelToUpdate);
logLabels("Labels to create", labelsToCreate);
console.log("Labels to delete", labelsToDelete);
console.log("");

Expand Down

0 comments on commit 5bf631c

Please sign in to comment.