(options: {
number: number;
labels: readonly string[];
triagePriority: TriagePriority;
dryRun: boolean;
})
| 10821 | } |
| 10822 | |
| 10823 | function syncPriorityLabel(options: { |
| 10824 | number: number; |
| 10825 | labels: readonly string[]; |
| 10826 | triagePriority: TriagePriority; |
| 10827 | dryRun: boolean; |
| 10828 | }): { labels: string[]; changed: boolean } { |
| 10829 | const nextLabels = nextPriorityLabels(options.labels, options.triagePriority); |
| 10830 | const labelsToRemove = options.labels.filter( |
| 10831 | (label) => PRIORITY_LABEL_NAMES.has(label) && !nextLabels.includes(label), |
| 10832 | ); |
| 10833 | const labelToAdd = nextLabels.find( |
| 10834 | (label) => PRIORITY_LABEL_NAMES.has(label) && !options.labels.includes(label), |
| 10835 | ); |
| 10836 | const changed = labelsToRemove.length > 0 || Boolean(labelToAdd); |
| 10837 | if (!changed) return { labels: nextLabels, changed }; |
| 10838 | if (options.dryRun) return { labels: nextLabels, changed }; |
| 10839 | if (labelToAdd) { |
| 10840 | const priorityLabel = PRIORITY_LABELS.find((label) => label.name === labelToAdd); |
| 10841 | if (priorityLabel) ensurePriorityLabel(priorityLabel); |
| 10842 | } |
| 10843 | for (const label of labelsToRemove) { |
| 10844 | ghWithRetry(["issue", "edit", String(options.number), "--remove-label", label]); |
| 10845 | } |
| 10846 | const syncedLabels = options.labels.filter((label) => !labelsToRemove.includes(label)); |
| 10847 | const added = |
| 10848 | labelToAdd !== undefined && |
| 10849 | tryAddOptionalLabel({ |
| 10850 | number: options.number, |
| 10851 | label: labelToAdd, |
| 10852 | currentLabels: syncedLabels, |
| 10853 | }); |
| 10854 | if (added) syncedLabels.push(labelToAdd); |
| 10855 | return { labels: syncedLabels, changed: labelsToRemove.length > 0 || added }; |
| 10856 | } |
| 10857 | |
| 10858 | function syncImpactLabels(options: { |
| 10859 | number: number; |
no test coverage detected