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

Function commentOnPR

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

Source from the content-addressed store, hash-verified

234};
235
236export async function commentOnPR({
237 prId,
238 githubToken,
239 body,
240 noDuplicates,
241}: CommentOnPRConfig) {
242 const isDuplicate = await isDuplicateComment({
243 prId,
244 githubToken,
245 body,
246 });
247 if (isDuplicate && noDuplicates) {
248 return body;
249 }
250 const response = await fetchWithRetries(
251 `https://api.github.com/repos/cloudflare/templates/issues/${prId}/comments`,
252 {
253 method: "POST",
254 headers: {
255 "Content-Type": "application/json",
256 Authorization: `Bearer ${githubToken}`,
257 Connection: "close",
258 },
259 body: JSON.stringify({
260 body,
261 }),
262 },
263 );
264 if (!response.ok) {
265 throw new Error(
266 `Error response from GitHub (${response.status}): ${await response.text()}`,
267 );
268 }
269 return body;
270}
271
272export async function isDuplicateComment({
273 prId,

Callers 2

depsInfoFunction · 0.90
previewFunction · 0.90

Calls 3

isDuplicateCommentFunction · 0.85
fetchWithRetriesFunction · 0.85
textMethod · 0.65

Tested by

no test coverage detected