MCPcopy Create free account
hub / github.com/electric-sql/electric / commentOnIssue

Function commentOnIssue

scripts/comment-on-release.mjs:247–285  ·  view source on GitHub ↗
(issueNumber, prNumbers, packages)

Source from the content-addressed store, hash-verified

245}
246
247async function commentOnIssue(issueNumber, prNumbers, packages) {
248 const packageList = packages
249 .map((p) => `- \`${p.name}@${p.version}\``)
250 .join(`\n`)
251
252 const prLinks = prNumbers.map((pr) => `#${pr}`).join(`, `)
253 const prWord = prNumbers.length === 1 ? `PR` : `PRs`
254
255 const body = `The ${prWord} fixing this issue (${prLinks}) has been released! :rocket:
256
257The following packages include the fix:
258
259${packageList}
260
261Thanks for reporting!`
262
263 try {
264 // Check if we already commented on this issue
265 const existingComments = execSync(
266 `gh api repos/${REPO}/issues/${issueNumber}/comments --jq '[.[] | select(.body | contains("A fix for this issue has been released!"))] | length'`,
267 { encoding: `utf8`, stdio: [`pipe`, `pipe`, `pipe`] }
268 ).trim()
269
270 if (parseInt(existingComments, 10) > 0) {
271 console.log(` Already commented on issue #${issueNumber}, skipping`)
272 return
273 }
274
275 // Use --body-file with stdin to avoid shell interpretation of backticks
276 execSync(`gh issue comment ${issueNumber} --repo ${REPO} --body-file -`, {
277 input: body,
278 encoding: `utf8`,
279 stdio: [`pipe`, `inherit`, `inherit`],
280 })
281 console.log(` Commented on issue #${issueNumber}`)
282 } catch (e) {
283 console.error(` Failed to comment on issue #${issueNumber}:`, e.message)
284 }
285}
286
287main().catch((e) => {
288 console.error(e)

Callers 1

mainFunction · 0.85

Calls 3

joinMethod · 0.45
mapMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected