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

Function isDuplicateComment

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

Source from the content-addressed store, hash-verified

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

Callers 1

commentOnPRFunction · 0.85

Calls 3

fetchWithRetriesFunction · 0.85
textMethod · 0.65
jsonMethod · 0.65

Tested by

no test coverage detected