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

Function commentOnPR

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

Source from the content-addressed store, hash-verified

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