| 211 | } |
| 212 | |
| 213 | async function findLinkedIssues(prNumber) { |
| 214 | const [owner, repo] = REPO.split(`/`) |
| 215 | const query = ` |
| 216 | query($owner: String!, $repo: String!, $pr: Int!) { |
| 217 | repository(owner: $owner, name: $repo) { |
| 218 | pullRequest(number: $pr) { |
| 219 | closingIssuesReferences(first: 10) { |
| 220 | nodes { |
| 221 | number |
| 222 | } |
| 223 | } |
| 224 | } |
| 225 | } |
| 226 | } |
| 227 | ` |
| 228 | |
| 229 | try { |
| 230 | const result = execSync( |
| 231 | `gh api graphql -f query='${query}' -F owner='${owner}' -F repo='${repo}' -F pr=${prNumber} --jq '.data.repository.pullRequest.closingIssuesReferences.nodes[].number'`, |
| 232 | { encoding: `utf8`, stdio: [`pipe`, `pipe`, `pipe`] } |
| 233 | ).trim() |
| 234 | |
| 235 | if (result) { |
| 236 | const issues = result.split(`\n`).map((n) => parseInt(n, 10)) |
| 237 | console.log(` PR #${prNumber} links to issues: ${issues.join(`, `)}`) |
| 238 | return issues |
| 239 | } |
| 240 | } catch (e) { |
| 241 | // PR might not have any linked issues |
| 242 | console.log(` PR #${prNumber} has no linked issues`) |
| 243 | } |
| 244 | return [] |
| 245 | } |
| 246 | |
| 247 | async function commentOnIssue(issueNumber, prNumbers, packages) { |
| 248 | const packageList = packages |