(options: {
number: number;
labels: readonly string[];
impactLabels: readonly ImpactLabelName[];
dryRun: boolean;
})
| 10856 | } |
| 10857 | |
| 10858 | function syncImpactLabels(options: { |
| 10859 | number: number; |
| 10860 | labels: readonly string[]; |
| 10861 | impactLabels: readonly ImpactLabelName[]; |
| 10862 | dryRun: boolean; |
| 10863 | }): { labels: string[]; changed: boolean } { |
| 10864 | const nextLabels = nextImpactLabels(options.labels, options.impactLabels); |
| 10865 | const currentLabelKeys = new Set(options.labels.map((label) => label.toLowerCase())); |
| 10866 | const nextLabelKeys = new Set(nextLabels.map((label) => label.toLowerCase())); |
| 10867 | const labelsToAdd = nextLabels.filter( |
| 10868 | (label): label is ImpactLabelName => |
| 10869 | IMPACT_LABEL_NAMES.has(label) && !currentLabelKeys.has(label.toLowerCase()), |
| 10870 | ); |
| 10871 | const labelsToRemove = options.labels.filter( |
| 10872 | (label) => IMPACT_LABEL_NAMES.has(label) && !nextLabelKeys.has(label.toLowerCase()), |
| 10873 | ); |
| 10874 | const changed = labelsToAdd.length > 0 || labelsToRemove.length > 0; |
| 10875 | if (!changed) return { labels: nextLabels, changed }; |
| 10876 | if (options.dryRun) return { labels: nextLabels, changed }; |
| 10877 | for (const label of labelsToRemove) { |
| 10878 | ghWithRetry(["issue", "edit", String(options.number), "--remove-label", label]); |
| 10879 | } |
| 10880 | const syncedLabels = options.labels.filter((label) => !labelsToRemove.includes(label)); |
| 10881 | let added = false; |
| 10882 | for (const label of labelsToAdd) { |
| 10883 | ensureImpactLabel(label); |
| 10884 | if (tryAddOptionalLabel({ number: options.number, label, currentLabels: syncedLabels })) { |
| 10885 | syncedLabels.push(label); |
| 10886 | added = true; |
| 10887 | } |
| 10888 | } |
| 10889 | return { labels: syncedLabels, changed: labelsToRemove.length > 0 || added }; |
| 10890 | } |
| 10891 | |
| 10892 | function syncMergeRiskLabels(options: { |
| 10893 | number: number; |
no test coverage detected