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

Function unconfirmedProductDirectionApplyBlockReason

src/clawsweeper.ts:3121–3172  ·  view source on GitHub ↗
(
  number: number,
  item: Pick<Item, "createdAt" | "labels">,
  reviewedUpdatedAt: string | undefined,
  reviewedAt: string | undefined,
)

Source from the content-addressed store, hash-verified

3119}
3120
3121function unconfirmedProductDirectionApplyBlockReason(
3122 number: number,
3123 item: Pick<Item, "createdAt" | "labels">,
3124 reviewedUpdatedAt: string | undefined,
3125 reviewedAt: string | undefined,
3126): string | null {
3127 if (!unconfirmedProductDirectionCloseEnabled()) {
3128 return "unconfirmed product-direction apply policy is disabled";
3129 }
3130 const ageBlock = unconfirmedProductDirectionAgeSkipReason(item, reviewedUpdatedAt, reviewedAt);
3131 if (ageBlock) return ageBlock;
3132 const exemptLabel = item.labels
3133 .map(normalizeLabelName)
3134 .find((label) => UNCONFIRMED_PRODUCT_DIRECTION_EXEMPT_LABELS.has(label));
3135 if (exemptLabel) return `${exemptLabel} exempts this PR from product-direction auto-close`;
3136
3137 const issue = ghJson<{ assignees?: unknown[] }>([
3138 "api",
3139 `repos/${targetRepo()}/issues/${number}`,
3140 "--jq",
3141 "{assignees:[.assignees[]? | {login:.login}]}",
3142 ]);
3143 if ((issue.assignees ?? []).length > 0) return "assigned PR has active human signal";
3144
3145 const pull = ghJson<{ requested_reviewers?: unknown[]; requested_teams?: unknown[] }>([
3146 "api",
3147 `repos/${targetRepo()}/pulls/${number}`,
3148 "--jq",
3149 "{requested_reviewers:[.requested_reviewers[]? | {login:.login}],requested_teams:[.requested_teams[]? | {slug:.slug}]}",
3150 ]);
3151 if ((pull.requested_reviewers ?? []).length > 0 || (pull.requested_teams ?? []).length > 0) {
3152 return "requested reviewers or teams indicate active review signal";
3153 }
3154
3155 const maintainerComments = maintainerAssociatedEntries(
3156 ghPaged<unknown>(`repos/${targetRepo()}/issues/${number}/comments`),
3157 );
3158 if (maintainerComments.length > 0) return "maintainer issue comment calibrates product direction";
3159
3160 const maintainerReviews = maintainerAssociatedEntries(
3161 ghPaged<unknown>(`repos/${targetRepo()}/pulls/${number}/reviews`),
3162 );
3163 if (maintainerReviews.length > 0) return "maintainer PR review calibrates product direction";
3164
3165 const maintainerInlineComments = maintainerAssociatedEntries(
3166 ghPaged<unknown>(`repos/${targetRepo()}/pulls/${number}/comments`),
3167 );
3168 if (maintainerInlineComments.length > 0) {
3169 return "maintainer inline review comment calibrates product direction";
3170 }
3171 return null;
3172}
3173
3174function unconfirmedProductDirectionApplyBlockReasonSafe(
3175 number: number,

Calls 7

targetRepoFunction · 0.85
hasMethod · 0.80
ghJsonFunction · 0.70
ghPagedFunction · 0.70

Tested by

no test coverage detected