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

Function syncIssueAdvisoryLabels

src/clawsweeper.ts:10926–10963  ·  view source on GitHub ↗
(options: {
  number: number;
  labels: readonly string[];
  state: IssueAdvisoryLabelState;
  dryRun: boolean;
})

Source from the content-addressed store, hash-verified

10924}
10925
10926function syncIssueAdvisoryLabels(options: {
10927 number: number;
10928 labels: readonly string[];
10929 state: IssueAdvisoryLabelState;
10930 dryRun: boolean;
10931}): { labels: string[]; changed: boolean } {
10932 const nextLabels = nextIssueAdvisoryLabels(options.labels, options.state);
10933 const currentLabelKeys = new Set(options.labels.map((label) => label.toLowerCase()));
10934 const nextLabelKeys = new Set(nextLabels.map((label) => label.toLowerCase()));
10935 const labelsToAdd = nextLabels.filter(
10936 (label) =>
10937 (isIssueAdvisoryLabel(label) || label.toLowerCase() === NO_STALE_LABEL) &&
10938 !currentLabelKeys.has(label.toLowerCase()),
10939 );
10940 const labelsToRemove = options.labels.filter(
10941 (label) =>
10942 (isIssueAdvisoryLabel(label) ||
10943 label.toLowerCase() === STALE_LABEL ||
10944 label.toLowerCase() === NO_STALE_LABEL) &&
10945 !nextLabelKeys.has(label.toLowerCase()),
10946 );
10947 const changed = labelsToAdd.length > 0 || labelsToRemove.length > 0;
10948 if (!changed) return { labels: nextLabels, changed };
10949 if (options.dryRun) return { labels: nextLabels, changed };
10950 for (const label of labelsToRemove) {
10951 ghWithRetry(["issue", "edit", String(options.number), "--remove-label", label]);
10952 }
10953 const syncedLabels = options.labels.filter((label) => !labelsToRemove.includes(label));
10954 let added = false;
10955 for (const label of labelsToAdd) {
10956 ensureIssueAdvisorySyncLabel(label);
10957 if (tryAddOptionalLabel({ number: options.number, label, currentLabels: syncedLabels })) {
10958 syncedLabels.push(label);
10959 added = true;
10960 }
10961 }
10962 return { labels: syncedLabels, changed: labelsToRemove.length > 0 || added };
10963}
10964
10965function syncTelegramVisibleProofLabel(options: {
10966 number: number;

Callers 1

applyDecisionsCommandFunction · 0.85

Calls 6

nextIssueAdvisoryLabelsFunction · 0.85
isIssueAdvisoryLabelFunction · 0.85
ghWithRetryFunction · 0.85
tryAddOptionalLabelFunction · 0.85
hasMethod · 0.80

Tested by

no test coverage detected