MCPcopy Create free account
hub / github.com/cloudflare/templates / isDuplicateComment

Function isDuplicateComment

cli/src/util.ts:272–293  ·  view source on GitHub ↗
({
	prId,
	githubToken,
	body,
}: CommentOnPRConfig)

Source from the content-addressed store, hash-verified

270}
271
272export async function isDuplicateComment({
273 prId,
274 githubToken,
275 body,
276}: CommentOnPRConfig) {
277 const response = await fetchWithRetries(
278 `https://api.github.com/repos/cloudflare/templates/issues/${prId}/comments`,
279 {
280 headers: {
281 Authorization: `Bearer ${githubToken}`,
282 Connection: "close",
283 },
284 },
285 );
286 if (!response.ok) {
287 throw new Error(
288 `Error response from GitHub (${response.status}): ${await response.text()}`,
289 );
290 }
291 const comments = (await response.json()) as Array<{ body: string }>;
292 return comments.find((comment) => comment.body === body);
293}
294
295export type PRState = "open" | "closed" | "all";
296

Callers 1

commentOnPRFunction · 0.85

Calls 3

fetchWithRetriesFunction · 0.85
textMethod · 0.65
jsonMethod · 0.65

Tested by

no test coverage detected