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

Function commentOnPR

scripts/comment-on-release.mjs:176–211  ·  view source on GitHub ↗
(prNumber, packages)

Source from the content-addressed store, hash-verified

174}
175
176async function commentOnPR(prNumber, packages) {
177 const packageList = packages
178 .map((p) => `- \`${p.name}@${p.version}\``)
179 .join(`\n`)
180
181 const body = `This PR has been released! :rocket:
182
183The following packages include changes from this PR:
184
185${packageList}
186
187Thanks for contributing to Electric!`
188
189 try {
190 // Check if we already commented on this PR
191 const existingComments = execSync(
192 `gh api repos/${REPO}/issues/${prNumber}/comments --jq '[.[] | select(.body | contains("This PR has been released!"))] | length'`,
193 { encoding: `utf8`, stdio: [`pipe`, `pipe`, `pipe`] }
194 ).trim()
195
196 if (parseInt(existingComments, 10) > 0) {
197 console.log(` Already commented on PR #${prNumber}, skipping`)
198 return
199 }
200
201 // Use --body-file with stdin to avoid shell interpretation of backticks
202 execSync(`gh pr comment ${prNumber} --repo ${REPO} --body-file -`, {
203 input: body,
204 encoding: `utf8`,
205 stdio: [`pipe`, `inherit`, `inherit`],
206 })
207 console.log(` Commented on PR #${prNumber}`)
208 } catch (e) {
209 console.error(` Failed to comment on PR #${prNumber}:`, e.message)
210 }
211}
212
213async function findLinkedIssues(prNumber) {
214 const [owner, repo] = REPO.split(`/`)

Callers 1

mainFunction · 0.85

Calls 3

joinMethod · 0.45
mapMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected