MCPcopy
hub / github.com/openclaw/clawsweeper / syncPrStatusLabel

Function syncPrStatusLabel

src/clawsweeper.ts:11126–11158  ·  view source on GitHub ↗
(options: {
  number: number;
  labels: readonly string[];
  statusKind: PrStatusLabelKind | null;
  dryRun: boolean;
})

Source from the content-addressed store, hash-verified

11124}
11125
11126function syncPrStatusLabel(options: {
11127 number: number;
11128 labels: readonly string[];
11129 statusKind: PrStatusLabelKind | null;
11130 dryRun: boolean;
11131}): { labels: string[]; changed: boolean } {
11132 const nextLabels = nextPrStatusLabels(options.labels, options.statusKind);
11133 const currentLabelKeys = new Set(options.labels.map((label) => label.toLowerCase()));
11134 const nextLabelKeys = new Set(nextLabels.map((label) => label.toLowerCase()));
11135 const labelsToRemove = options.labels.filter(
11136 (label) => PR_STATUS_LABEL_NAMES.has(label) && !nextLabelKeys.has(label.toLowerCase()),
11137 );
11138 const labelToAdd = nextLabels.find(
11139 (label) => PR_STATUS_LABEL_NAMES.has(label) && !currentLabelKeys.has(label.toLowerCase()),
11140 );
11141 const changed = labelsToRemove.length > 0 || Boolean(labelToAdd);
11142 if (!changed) return { labels: nextLabels, changed };
11143 if (options.dryRun) return { labels: nextLabels, changed };
11144 if (options.statusKind && labelToAdd) ensurePrStatusLabel(options.statusKind);
11145 for (const label of labelsToRemove) {
11146 ghWithRetry(["issue", "edit", String(options.number), "--remove-label", label]);
11147 }
11148 const syncedLabels = options.labels.filter((label) => !labelsToRemove.includes(label));
11149 const added =
11150 labelToAdd !== undefined &&
11151 tryAddOptionalLabel({
11152 number: options.number,
11153 label: labelToAdd,
11154 currentLabels: syncedLabels,
11155 });
11156 if (added) syncedLabels.push(labelToAdd);
11157 return { labels: syncedLabels, changed: labelsToRemove.length > 0 || added };
11158}
11159
11160function ensureTelegramVisibleProofLabel(): void {
11161 try {

Callers 2

applyDecisionsCommandFunction · 0.85

Calls 5

nextPrStatusLabelsFunction · 0.85
ensurePrStatusLabelFunction · 0.85
ghWithRetryFunction · 0.85
tryAddOptionalLabelFunction · 0.85
hasMethod · 0.80

Tested by

no test coverage detected